package com.dragon.mmochat.service;

import java.awt.Color;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataIntegrityViolationException;

import com.dragon.mmochat.MmochatConstant;
import com.dragon.mmochat.MmochatMain;
import com.dragon.mmochat.message.Mmochat_12_15S;
import com.dragon.mmochat.message.Mmochat_12_18S;
import com.dragon.mmochat.message.Mmochat_12_23S;
import com.dragon.mmochat.message.Mmochat_13_10C;
import com.dragon.mmochat.message.Mmochat_13_11C;
import com.dragon.mmochat.message.Mmochat_13_12C;
import com.dragon.mmochat.message.Mmochat_13_14C;
import com.dragon.mmochat.message.Mmochat_13_15C;
import com.dragon.mmochat.message.Mmochat_13_16C;
import com.dragon.mmochat.message.Mmochat_13_17C;
import com.dragon.mmochat.message.Mmochat_13_18C;
import com.dragon.mmochat.message.Mmochat_13_19C;
import com.dragon.mmochat.message.Mmochat_13_20C;
import com.dragon.mmochat.message.Mmochat_13_21C;
import com.dragon.mmochat.message.Mmochat_13_22C;
import com.dragon.mmochat.message.Mmochat_13_23C;
import com.dragon.mmochat.message.Mmochat_13_24C;
import com.dragon.mmochat.message.Mmochat_13_25C;
import com.dragon.mmochat.message.Mmochat_13_26C;
import com.dragon.mmochat.message.Mmochat_13_27C;
import com.dragon.mmochat.message.Mmochat_13_28C;
import com.dragon.mmochat.message.Mmochat_13_29C;
import com.dragon.mmochat.message.Mmochat_13_2C;
import com.dragon.mmochat.message.Mmochat_13_30C;
import com.dragon.mmochat.message.Mmochat_13_31C;
import com.dragon.mmochat.message.Mmochat_13_32C;
import com.dragon.mmochat.message.Mmochat_13_33C;
import com.dragon.mmochat.message.Mmochat_13_34C;
import com.dragon.mmochat.message.Mmochat_13_4C;
import com.dragon.mmochat.message.Mmochat_13_4S;
import com.dragon.mmochat.message.Mmochat_13_5C;
import com.dragon.mmochat.message.Mmochat_13_5S;
import com.dragon.mmochat.message.Mmochat_13_6C;
import com.dragon.mmochat.message.Mmochat_13_7C;
import com.dragon.mmochat.message.Mmochat_13_8C;
import com.dragon.mmochat.message.Mmochat_13_9C;
import com.dragon.mmochat.message.Mmochat_1_10S;
import com.dragon.mmochat.message.Mmochat_1_16S;
import com.dragon.mmochat.message.Mmochat_1_23S;
import com.dragon.mmochat.message.Mmochat_1_7S;
import com.dragon.mmochat.message.Mmochat_4_11S;
import com.dragon.mmochat.message.Mmochat_4_12S;
import com.dragon.mmochat.message.Mmochat_5_10S;
import com.dragon.mmochat.message.Mmochat_5_1S;
import com.dragon.mmochat.message.Mmochat_SendSuggestAward;
import com.dragon.mmochat.model.MmochatChenHao;
import com.dragon.mmochat.model.MmochatDailyActivity;
import com.dragon.mmochat.model.MmochatDelayPay;
import com.dragon.mmochat.model.MmochatNews;
import com.dragon.mmochat.model.MmochatRolePayInfo;
import com.dragon.mmochat.model.MmochatStrengthDrug;
import com.dragon.mmochat.model.MmochatTeam;
import com.dragon.mmochat.model.activity.MmochatDaoActivity;
import com.dragon.mmochat.model.activity.MmochatDaoRole;
import com.dragon.mmochat.model.activity.MmochatFastLotteryAward;
import com.dragon.mmochat.model.activity.MmochatFastLotteryAwardTitle;
import com.dragon.mmochat.model.activity.MmochatFastLotteryRole;
import com.dragon.mmochat.model.activity.MmochatLotteryRole;
import com.dragon.mmochat.model.activity.MmochatPayFastLotteryInfo;
import com.dragon.mmochat.model.activity.MmochatPayLotteryInfo;
import com.dragon.mmochat.model.activity.MmochatSystemState;
import com.dragon.mmochat.model.attackMode.MmochatAttackModeOfNormal;
import com.dragon.mmochat.model.battle.record.MmochatBattleRecord;
import com.dragon.mmochat.model.deal.MmochatBorrowRecord;
import com.dragon.mmochat.model.enumType.MmochatBattleType;
import com.dragon.mmochat.model.enumType.MmochatBigMoneyCostType;
import com.dragon.mmochat.model.enumType.MmochatBigMoneyEarnType;
import com.dragon.mmochat.model.enumType.MmochatBossLevelType;
import com.dragon.mmochat.model.enumType.MmochatCommonObjectType;
import com.dragon.mmochat.model.enumType.MmochatDailyActivityType;
import com.dragon.mmochat.model.enumType.MmochatDelayPayState;
import com.dragon.mmochat.model.enumType.MmochatDrugType;
import com.dragon.mmochat.model.enumType.MmochatEquipPlaceType;
import com.dragon.mmochat.model.enumType.MmochatEquipQualityType;
import com.dragon.mmochat.model.enumType.MmochatEquipType;
import com.dragon.mmochat.model.enumType.MmochatFamilyType;
import com.dragon.mmochat.model.enumType.MmochatLifeSkillType;
import com.dragon.mmochat.model.enumType.MmochatMaterialType;
import com.dragon.mmochat.model.enumType.MmochatMoneyType;
import com.dragon.mmochat.model.enumType.MmochatNpcItemType;
import com.dragon.mmochat.model.enumType.MmochatObjOwnerState;
import com.dragon.mmochat.model.enumType.MmochatObjectType;
import com.dragon.mmochat.model.enumType.MmochatPackageGridType;
import com.dragon.mmochat.model.enumType.MmochatPayLotteryState;
import com.dragon.mmochat.model.enumType.MmochatPetStateType;
import com.dragon.mmochat.model.enumType.MmochatPetType;
import com.dragon.mmochat.model.enumType.MmochatPropEffectType;
import com.dragon.mmochat.model.enumType.MmochatPropType;
import com.dragon.mmochat.model.enumType.MmochatQQNewsType;
import com.dragon.mmochat.model.enumType.MmochatRoleAttributeType;
import com.dragon.mmochat.model.enumType.MmochatRoleBmpType;
import com.dragon.mmochat.model.enumType.MmochatRoleDealState;
import com.dragon.mmochat.model.enumType.MmochatRoleType;
import com.dragon.mmochat.model.enumType.MmochatServerType;
import com.dragon.mmochat.model.enumType.MmochatShopClassType;
import com.dragon.mmochat.model.enumType.MmochatShopType;
import com.dragon.mmochat.model.enumType.MmochatSmallMoneyCostType;
import com.dragon.mmochat.model.enumType.MmochatSmallMoneyEarnType;
import com.dragon.mmochat.model.enumType.MmochatSpecialSkillType;
import com.dragon.mmochat.model.enumType.MmochatSuperMachineType;
import com.dragon.mmochat.model.enumType.MmochatTaskStateType;
import com.dragon.mmochat.model.enumType.MmochatTaskType;
import com.dragon.mmochat.model.enumType.MmochatTeamStateType;
import com.dragon.mmochat.model.map.MmochatMap;
import com.dragon.mmochat.model.map.MmochatPoint;
import com.dragon.mmochat.model.object.MmochatCommonObject;
import com.dragon.mmochat.model.object.MmochatDrug;
import com.dragon.mmochat.model.object.MmochatEquip;
import com.dragon.mmochat.model.object.MmochatMaterial;
import com.dragon.mmochat.model.object.MmochatPackageGrid;
import com.dragon.mmochat.model.object.MmochatProp;
import com.dragon.mmochat.model.object.MmochatPropEffect;
import com.dragon.mmochat.model.object.MmochatSuperMachine;
import com.dragon.mmochat.model.role.MmochatMonsterFactory;
import com.dragon.mmochat.model.role.MmochatPet;
import com.dragon.mmochat.model.role.MmochatPlayer;
import com.dragon.mmochat.model.role.MmochatRole;
import com.dragon.mmochat.model.role.MmochatTempNpc;
import com.dragon.mmochat.model.roleDeal.MmochatRoleDeal;
import com.dragon.mmochat.model.skill.MmochatSpecialSkill;
import com.dragon.mmochat.model.skill.lifeSkill.MmochatLifeSkill;
import com.dragon.mmochat.model.task.MmochatNpcBattle;
import com.dragon.mmochat.model.task.MmochatTask;
import com.dragon.mmochat.model.task.MmochatTempTask;
import com.dragon.mmochat.util.CreateTlvWin;
import com.dragon.mmochat.util.MmochatUtil;
import com.google.gson.reflect.TypeToken;
import com.skymobi.handler.SkymobiHandler;
import com.skymobi.message.SkymobiProtocolMessage;
import com.skymobi.message.widget.AddDataTLV;
import com.skymobi.message.widget.AddEditBoxTLV;
import com.skymobi.message.widget.ClearDataTLV;
import com.skymobi.message.widget.CloseWinTLV;
import com.skymobi.message.widget.CreateEditBoxTLV;
import com.skymobi.message.widget.CreateMsgBoxTLV;
import com.skymobi.message.widget.CtrlTLVStructureRequest;
import com.skymobi.message.widget.SendDataTLV;
import com.skymobi.message.widget.ShowWaitingMsgBoxTLV;
import com.skymobi.message.widget.TLVStructure;
import com.skymobi.message.widget.WinType;
import com.skymobi.service.SkymobiService;
import com.skymobi.util.Text;

public class MmochatPropService {
	private static Logger log = LoggerFactory
			.getLogger(MmochatPropService.class);

	public static ScheduledExecutorService checkPropEffectThread = Executors
			.newScheduledThreadPool(1);
	public static ScheduledExecutorService checkFlyMachineThread = Executors
			.newScheduledThreadPool(1);
	public static ScheduledExecutorService updateSqlAfterUsePropThread = Executors
			.newScheduledThreadPool(1);

	// 限时出售道具的时间点
	public static List<String> limitSellDateList = new ArrayList<String>();

	// 需要保存使用道具后数据库的角色队列
	public static ConcurrentLinkedQueue<MmochatPlayer> needToSavePropSqlPlayerQueue = new ConcurrentLinkedQueue<MmochatPlayer>();

	// 充值抽奖活动
	public static MmochatPayLotteryInfo payLotteryInfo = null;

	// 即时充值抽奖活动
	public static MmochatPayFastLotteryInfo fastPayLotteryInfo = null;

	// 刷道活动
	public static MmochatDaoActivity daoActivityInfo = null;

	public static int firstPayAwardCount = 0; // 首充奖励人数，维护后置0

	public void init() {
		if (!MmochatMain.openMergeServer) {
			checkPropEffectThread.scheduleWithFixedDelay(new checkPropEffect(),
					1, 1, TimeUnit.MINUTES);
			checkFlyMachineThread.scheduleWithFixedDelay(
					new checkFlyMachineUseTime(), 1, 1, TimeUnit.HOURS);
			updateSqlAfterUsePropThread.scheduleAtFixedRate(
					new saveSqlAfterUsePropAction(), 60000, 23000,
					TimeUnit.MILLISECONDS);
		}
	}

	public static void addlimitSellDate(String date) {
		limitSellDateList.add(date);
	}

	public static boolean isTodayLimitSellOpen() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		String today = sdf.format(new Date());
		if (limitSellDateList.contains(today)) {
			return true;
		}
		return false;
	}

	// 参加刷道比赛
	public static void dealDaoActivity(MmochatPlayer me, int add) {
		if (daoActivityInfo != null
				&& daoActivityInfo.getState() == MmochatPayLotteryState.开始统计) {
			daoActivityInfo.addDao(me, add);
		}
	}

	// 即时充值抽奖活动
	public static void dealFastPayLottery(MmochatPlayer me, int payMoney) {
		if (fastPayLotteryInfo != null
				&& fastPayLotteryInfo.getState() == MmochatPayLotteryState.开始统计) {
			int times = fastPayLotteryInfo
					.dealRolePay(me.getRoleId(), payMoney);
			if (times > 0) {
				String content = MmochatUtil.wrapColor("您获得" + times + "次"
						+ MmochatUtil.wrapColor("<即开型充值抽奖>", Color.red)
						+ "活动抽奖机会，请按9键进入<充值元宝>-<即开型充值抽奖活动>"
						+ "界面进行抽奖!活动结束后无法抽奖，请及时抽奖!", Color.yellow);
				MmochatGmService.sendKufuPrivateMsg(me.getRoleId(), content,
						false);
			}
		}
	}

	// 平均每秒最多能执行大约2次，在高峰期，1500人同时在线情况下，平均每人12.5分钟会保存一次数据库
	class saveSqlAfterUsePropAction implements Runnable {
		@Override
		public void run() {
			try {
				if (System.currentTimeMillis() < MmochatConstant.startSaveSqlAfterJobTick) {
					return;
				}
				if (!MmochatConstant.saveSqlAfterActiveLock) {
					needToSavePropSqlPlayerQueue.clear();
					return;
				}
				MmochatPlayer me = needToSavePropSqlPlayerQueue.poll();
				try {
					if (me != null) {
						MmochatPlayer he = MmochatMainService.offlinePlayers
								.get(me.getRoleId());
						if (he != null && me != he) {
							me = he;
						}
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
				// 为防止死锁等导致一条操作无法结束，每次启动新的线程来执行
				new Thread(new doSql(me)).start();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	class doSql extends Thread {
		MmochatPlayer me = null;

		public doSql(MmochatPlayer m) {
			me = m;
		}

		public void run() {
			try {
				if (me != null) {
					MmochatDao.updateRoleAfterUseProp(me);
					log.debug(me.getName() + "执行updateRoleAfterUseProp操作!");
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	// 更新神行法宝体力
	class checkFlyMachineUseTime implements Runnable {
		@Override
		public void run() {
			try {
				Date now = new Date();
				for (MmochatPlayer role : MmochatMainService.players.values()) {
					try {
						// 更新包裹中的神行法宝体力
						if (role.getMyPackage() != null) {
							Mmochat_5_1S pack = new Mmochat_5_1S();
							for (MmochatPackageGrid grid : role.getMyPackage()
									.values()) {
								if (grid != null && grid.getObject() != null) {
									if (grid.getObject().getType() == MmochatSuperMachineType.神行法宝) {
										MmochatCommonObject superMachine = grid
												.getObject();
										// 更新法宝体力
										if (superMachine
												.getFlyMachineCanUseTotalValue() > 0) {
											long lastTime = now.getTime()
													- superMachine
															.getFlyMachineUseStartTime();
											if (lastTime > 0) {
												long hour = lastTime
														/ MmochatConstant.MS_PER_HOUR;
												long useValue = hour
														* MmochatCommonObject
																.getFlyMachineUsePerHour(
																		superMachine
																				.getFlyMachineSpeedLevel(),
																		superMachine
																				.getFlyMachineFlyLevel());
												long restValue = superMachine
														.getFlyMachineCanUseTotalValue()
														- useValue;
												if (restValue <= 0) {
													// 体力用光
													superMachine
															.setFlyMachineCanUseTotalValue(0);
													superMachine
															.setFlyMachineCanUseValue(0);
													superMachine
															.setFlyMachineUseStartTime(now
																	.getTime());
													MmochatChatService
															.sendSystemMsgToPerson(
																	role,
																	"您的"
																			+ MmochatUtil
																					.wrapColor(
																							superMachine
																									.getName(),
																							Color.yellow)
																			+ "体力已用光，法宝效果消失，"
																			+ "请补充法宝体力(按9键打开商城有售补充体力道具)。");
												} else {
													superMachine
															.setFlyMachineCanUseValue(restValue);
												}
												pack.addGrid(grid);
											}
										}
									}
								}
							}
							// 更新玩家包裹
							if (pack.hasGrid()) {
								MmochatUtil
										.sendCommonPack(MmochatHandle_SendChat
												.getCommonHandler(), role, pack);
								// 更新玩家状态
								Mmochat_1_16S pack2 = new Mmochat_1_16S();
								pack2.setMe(role);
								MmochatUtil.sendCommonPack(
										MmochatHandle_SendChat
												.getCommonHandler(), role,
										pack2);
							}
						}

						// 更新仓库中的神行法宝体力
						if (role.getMyStorage() != null) {
							for (MmochatPackageGrid grid : role.getMyStorage()
									.values()) {
								if (grid != null && grid.getObject() != null) {
									if (grid.getObject().getType() == MmochatSuperMachineType.神行法宝) {
										MmochatCommonObject superMachine = grid
												.getObject();
										// 更新法宝体力
										if (superMachine
												.getFlyMachineCanUseTotalValue() > 0) {
											long lastTime = now.getTime()
													- superMachine
															.getFlyMachineUseStartTime();
											if (lastTime > 0) {
												long hour = lastTime
														/ MmochatConstant.MS_PER_HOUR;
												long useValue = hour
														* MmochatCommonObject
																.getFlyMachineUsePerHour(
																		superMachine
																				.getFlyMachineSpeedLevel(),
																		superMachine
																				.getFlyMachineFlyLevel());
												long restValue = superMachine
														.getFlyMachineCanUseTotalValue()
														- useValue;
												if (restValue <= 0) {
													// 体力用光
													superMachine
															.setFlyMachineCanUseTotalValue(0);
													superMachine
															.setFlyMachineCanUseValue(0);
													superMachine
															.setFlyMachineUseStartTime(now
																	.getTime());
												} else {
													superMachine
															.setFlyMachineCanUseValue(restValue);
												}
											}
										}
									}
								}
							}
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	// 上线检查时间道具是否过期
	public static void checkRoleProp(MmochatPlayer me) {
		try {
			if (me != null) {
				// 检查道具是否过期
				boolean needUpdate = false;
				long oldState = me.getStateValue(null);
				for (MmochatPropEffect propEffect : me.getPropEffects()
						.values()) {
					try {
						if (propEffect != null) {
							if (propEffect.getPropType().getEffectType() == MmochatPropEffectType.时间) {
								Date now = new Date();
								if (now.getTime() - propEffect.getStartTime() >= propEffect
										.getRestAmount()) {
									// 道具时间已经结束
									needUpdate = true;
									me.delPropEffect(propEffect.getPropType()
											.getEffectKey());

									if (propEffect.getPropType() == MmochatPropType.驱魔符
											|| propEffect.getPropType() == MmochatPropType.龙涎香) {
										// 下发更新驱魔香效果
										Mmochat_1_23S avoidPack = new Mmochat_1_23S();
										avoidPack.setMe(me);
										MmochatUtil.sendCommonPack(me,
												avoidPack);
									}
								}
							}
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				me.checkVipPackageSpace();

				// 更新状态
				if (me.getStateValue(null) != oldState) {
					Mmochat_1_16S pack = new Mmochat_1_16S();
					pack.setMe(me);
					MmochatUtil.sendCommonPack(me, pack);
				}

				if (needUpdate) {
					List<Object[]> updateObjs = new ArrayList<Object[]>();
					updateObjs.add(new Object[] { me.getGson_propEffects(),
							me.getRoleId() });
					try {
						MmochatDao.batchUpdateRolePropEffect(updateObjs);
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	// 定时检查时间道具是否过期
	class checkPropEffect implements Runnable {
		@Override
		public void run() {
			try {
				List<Object[]> updateObjs = new ArrayList<Object[]>();
				for (MmochatPlayer me : MmochatMainService.players.values()) {
					try {
						if (me != null) {
							// 检查道具是否过期
							boolean needUpdate = false;
							long oldState = me.getStateValue(null);
							for (MmochatPropEffect propEffect : me
									.getPropEffects().values()) {
								try {
									if (propEffect != null) {
										if (propEffect.getPropType()
												.getEffectType() == MmochatPropEffectType.时间) {
											Date now = new Date();
											if (now.getTime()
													- propEffect.getStartTime() >= propEffect
													.getRestAmount()) {
												// 道具时间已经结束
												needUpdate = true;
												me.delPropEffect(propEffect
														.getPropType()
														.getEffectKey());

												if (propEffect.getPropType() == MmochatPropType.驱魔符
														|| propEffect
																.getPropType() == MmochatPropType.龙涎香) {
													// 下发更新驱魔香效果
													Mmochat_1_23S avoidPack = new Mmochat_1_23S();
													avoidPack.setMe(me);
													MmochatUtil
															.sendCommonPack(
																	MmochatHandle_SendChat
																			.getCommonHandler(),
																	me,
																	avoidPack);
												}
											}
										}
									}
								} catch (Exception e) {
									e.printStackTrace();
								}
							}
							me.checkVipPackageSpace();

							// 更新状态
							if (me.getStateValue(null) != oldState) {
								Mmochat_1_16S pack = new Mmochat_1_16S();
								pack.setMe(me);
								MmochatUtil.sendCommonPack(
										MmochatHandle_SendChat
												.getCommonHandler(), me, pack);
							}
							if (needUpdate) {
								updateObjs.add(new Object[] {
										me.getGson_propEffects(),
										me.getRoleId() });
							}

							// 检查是否有称号过期
							for (MmochatChenHao chenhao : me.getChenHaoMap()
									.values()) {
								if (chenhao.isTimeOut()) {
									MmochatChenHao
											.delAndUpdateChenHaoAndSaveSql(me
													.getRoleId(), chenhao
													.getType());
								}
							}

							// 检查限时类道具
							me.checkTimedProp();
						}
					} catch (Exception e) {
						e.printStackTrace();
					}

					// 增加竞技点
					try {
						if (MmochatMain.serverType != MmochatServerType.跨服战服务器) {
							if (me != null) {
								if (me.getPk_score() < MmochatConstant.onlinePkScoreLimit) {
									me
											.addPk_score(MmochatConstant.addPkScorePerUnit);
								}
							}
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				if (updateObjs.size() > 0) {
					long t = System.currentTimeMillis();
					try {
						MmochatDao.batchUpdateRolePropEffect(updateObjs);
					} catch (Exception e) {
						e.printStackTrace();
					}
					if (MmochatConstant.testCheckPropSqlTimeOut) {
						log.error("batchUpdateRolePropEffect cost time:"
								+ (System.currentTimeMillis() - t) + "ms");
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	// propOwner:道具所有者; propId: 道具ID; propUser:道具使用者
	// 使用道具,返回String[]{errMsg, successMsg, returnTag}
	// errMsg != null则出错,否则表示使用成功(successMsg可能为null)
	// returnTag != null 表示调用方可以立即返回
	@SuppressWarnings("deprecation")
	public static Map<Integer, Object> useProp(MmochatPlayer propOwner,
			int gridId, MmochatRole propUser) {
		Map<Integer, Object> msgMap = new HashMap<Integer, Object>();
		MmochatPlayer otherUser;
		String systemMsg;
		MmochatPackageGrid grid;
		// 下发更新包裹数据
		boolean addPropCost = true;
		MmochatPropType propType = null;
		Mmochat_5_1S gridNeedUpdatePack = new Mmochat_5_1S();
		synchronized (propOwner) {
			grid = propOwner.getMyPackage().get(gridId);
			if (grid == null || grid.getObject() == null) {
				msgMap.put(0, "没有找到此道具!");
				return msgMap;
			}
			if (!grid.isCanUse()) {
				msgMap.put(0, "此包裹格子无法使用!");
				return msgMap;
			}
			MmochatCommonObject prop = grid.getObject();
			if (prop == null) {
				msgMap.put(0, "没有找到此道具!");
				return msgMap;
			}
			propType = prop.getPropType();
			if (propType == null) {
				msgMap.put(0, "此物品无法使用!");
				return msgMap;
			}
			switch (propType.getUseRole()) {
			case 玩家:
				if (!(propUser instanceof MmochatPlayer)) {
					msgMap.put(0, "此道具只能给人使用!");
					return msgMap;
				}
				break;
			case 宠物:
				if (!(propUser instanceof MmochatPet)) {
					msgMap.put(0, "此道具只能给宠物使用!请打开宠物信息面板,点击<喂养>使用!");
					return msgMap;
				}
				break;
			case 所有:
				break;
			default:
				break;
			}
			switch (propType.getUseCondition()) {
			case 被动使用: {
				msgMap.put(0, "此道具为被动道具,在特定情况下自动消耗,无法直接使用!");
				return msgMap;
			}
			case 非战斗时使用: {
				if (propOwner.isInBattle()) {
					msgMap.put(0, "此道具只能在非战斗中使用!");
					return msgMap;
				}
				break;
			}
			case 战斗时使用: {
				if (!propOwner.isInBattle()) {
					msgMap.put(0, "此道具只能在战斗中使用!");
					return msgMap;
				}
				break;
			}
			case 任何时候使用: {
				break;
			}
			default:
				break;
			}
			if (prop.isCanOverlap() && prop.getOverlapNum() <= 0
					|| !prop.isCanOverlap() && prop.getCurPropAmount() <= 0) {
				msgMap.put(0, "此道具已经用完!");
				grid.setObject(null);
				// 下发更新包裹数据
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.addGrid(grid);
				MmochatUtil.sendCommonPack(propOwner, pack);
				return msgMap;
			}
			long oldMeStateValue = propOwner.getStateValue(null);
			otherUser = null;
			if (propUser instanceof MmochatPlayer) {
				otherUser = (MmochatPlayer) propUser;
				if (otherUser == propOwner) {
					otherUser = null;
				}
			}
			// 状态型道具,将状态保存到玩家道具状态中
			if (propType.getEffectType() == MmochatPropEffectType.时间
					|| propType.getEffectType() == MmochatPropEffectType.计量) {
				if (otherUser != null) {
					// 状态型道具只能给自己或宠物使用，不能给其它人使用
					msgMap.put(0, "此道具只限自己或自己的宠物使用!");
					return msgMap;
				}
				// 互斥道具处理
				if (propType.getEffectKey() == MmochatPropType.武神光环
						.getEffectKey()
						|| propType.getEffectKey() == MmochatPropType.风神护体
								.getEffectKey()) {
					// 清除之前的护体状态
					propOwner
							.delPropEffect(MmochatPropType.武神光环.getEffectKey());
					propOwner
							.delPropEffect(MmochatPropType.风神护体.getEffectKey());
				}

				// 强化丹
				if (MmochatStrengthDrug.isStrengthDrugProp(propType)) {
					// 清除之前的强化丹状态
					for (int effectKey = MmochatConstant.minStrenthDrugEffectKey; effectKey <= MmochatConstant.maxStrenthDrugEffectKey; effectKey++) {
						propOwner.delPropEffect(effectKey);
					}
				}

				if (propType.getEffectKey() == MmochatPropType.驱魔符
						.getEffectKey()) {
					// 清除之前的驱魔状态
					MmochatPropEffect effect = propOwner.getPropEffects().get(
							MmochatPropType.龙涎香.getEffectKey());
					if (effect != null) {
						msgMap.put(0, "您已经使用了龙涎香效果，无需再使用驱魔符!");
						return msgMap;
					}
					propOwner.delPropEffect(MmochatPropType.驱魔符.getEffectKey());
				}
				if (propType.getEffectKey() == MmochatPropType.龙涎香
						.getEffectKey()) {
					propOwner.delPropEffect(MmochatPropType.驱魔符.getEffectKey());
				}

				if (propType.getEffectKey() == MmochatPropType.系统双倍令
						.getEffectKey()) {
					// 每次只能使用一个
					if (propOwner.hasPropEffect(MmochatPropType.系统双倍令
							.getEffectKey())) {
						msgMap.put(0, "此道具每次只能使用一个，您当前还有系统双倍令效果!");
						return msgMap;
					}
					// 系统双倍时不能使用
					if (MmochatSystemState.isSystemDoubleAward()) {
						msgMap.put(0, "当前正在进行官方免费系统双倍活动，无须使用此道具!");
						return msgMap;
					}
					// 仅限每周一、周三的22:00至23:00期间使用
					Date now = new Date();
					if ((now.getDay() != 3 && now.getDay() != 1)
							|| now.getHours() != 22) {
						msgMap.put(0, "此道具仅限周一或周三的22:00至23:00期间使用!现在无法使用。");
						return msgMap;
					}
				}

				if (propType.getEffectKey() == MmochatPropType.鬼灵珠
						.getEffectKey()) {
					if (propOwner.getLevel() < 100) {
						// 低级限周六周日使用
						Date now = new Date();
						if (now.getDay() != 6 && now.getDay() != 0) {
							msgMap.put(0, "100级以下的用户权限周六周日使用此道具!");
							return msgMap;
						}
					}
				}

				// 增加状态时间
				MmochatPropEffect effect = propOwner.getPropEffects().get(
						propType.getEffectKey());
				if (effect != null) {
					// 鬼灵珠限制累计时间
					if (propType.getEffectKey() == MmochatPropType.鬼灵珠
							.getEffectKey()) {
						if (effect.getRestAmount()
								- (System.currentTimeMillis() - effect
										.getStartTime()) >= MmochatConstant.maxEffectTimeOfGhostBall) {
							msgMap.put(0, "您当前的鬼灵珠时间已经够久了，不能再继续使用了!");
							return msgMap;
						}
					}
					effect.addAmount(propType.getEffectAmount());
				} else {
					effect = new MmochatPropEffect();
					effect.setPropType(propType);
					effect.setRestAmount(propType.getEffectAmount());
					propOwner.addPropEffect(effect);
				}

				if (propType.getEffectKey() == MmochatPropType.驱魔符
						.getEffectKey()
						|| propType.getEffectKey() == MmochatPropType.龙涎香
								.getEffectKey()) {
					// 下发更新驱魔香效果
					Mmochat_1_23S avoidPack = new Mmochat_1_23S();
					avoidPack.setMe(propOwner);
					MmochatUtil.sendCommonPack(propOwner, avoidPack);
				}

				// 扣除道具
				if (prop.isCanOverlap()) {
					prop.delOverlapNum(1);
					if (prop.getOverlapNum() <= 0) {
						grid.setObject(null);
					}
				} else {
					prop.delAmount(1);
					if (prop.getCurPropAmount() <= 0) {
						grid.setObject(null);
					}
				}
				MmochatStatisticsService.addPropCost(propType, 1);

				// 下发更新包裹数据
				Mmochat_5_1S pack = new Mmochat_5_1S();
				pack.addGrid(grid);
				MmochatUtil.sendCommonPack(propOwner, pack);

				// 放入队列中
				if (!needToSavePropSqlPlayerQueue.contains(propOwner)
						&& !MmochatGmService.isSystemExit()) {
					needToSavePropSqlPlayerQueue.add(propOwner);
				}

				// 特殊处理
				if (propOwner.getStateValue(null) != oldMeStateValue) {
					// 更新状态
					Mmochat_1_16S pack1 = new Mmochat_1_16S();
					pack1.setMe(propOwner);
					MmochatUtil.sendCommonPack(propOwner, pack1);
				}
				propOwner.checkVipPackageSpace();

				if (propType.getEffectKey() == MmochatPropType.大血池
						.getEffectKey()
						|| propType.getEffectKey() == MmochatPropType.中血池
								.getEffectKey()
						|| propType.getEffectKey() == MmochatPropType.小血池
								.getEffectKey()
						|| propType.getEffectKey() == MmochatPropType.大血石
								.getEffectKey()
						|| propType.getEffectKey() == MmochatPropType.中血石
								.getEffectKey()
						|| propType.getEffectKey() == MmochatPropType.小血石
								.getEffectKey()
						|| propType.getEffectKey() == MmochatPropType.大法池
								.getEffectKey()
						|| propType.getEffectKey() == MmochatPropType.中法池
								.getEffectKey()
						|| propType.getEffectKey() == MmochatPropType.小法池
								.getEffectKey()) {
					// 道具:血池法池效果
					MmochatPropService.useAutoAddBloodSpritProp(propOwner);

					// 更新头像图标信息
					Mmochat_1_7S pack1 = new Mmochat_1_7S(false);
					pack1.setMe(propOwner);
					MmochatUtil.sendCommonPack(propOwner, pack1);
				}

				String effectInfo = MmochatUtil.wrapColor(effect.getPropType()
						.getEffectInfo(), Color.yellow);
				effectInfo += "还有";
				if (effect.getPropType().getEffectType() == MmochatPropEffectType.时间) {
					long usedTime = new Date().getTime()
							- effect.getStartTime();
					long time = effect.getRestAmount() - usedTime;
					effectInfo += MmochatUtil.wrapColor(MmochatUtil
							.getTimeString(time), Color.green);
				} else if (effect.getPropType().getEffectType() == MmochatPropEffectType.计量) {
					effectInfo += MmochatUtil.wrapColor(effect.getRestAmount(),
							Color.green);
				}

				msgMap.put(1, "您使用了" + prop.getPropType().toString() + ","
						+ effectInfo + "。在主界面按左软键-查看道具状态,可以查看到道具当前效果!");
				return msgMap;
			}
			systemMsg = null;
			// 非被动道具,瞬间效果的道具
			switch (prop.getPropType()) {
			case 经验解冻丹: {
				MmochatPropEffect effect1 = propOwner.getPropEffects().get(
						MmochatPropType.经验冻结丹.getEffectKey());
				if (effect1 == null) {
					msgMap.put(0, "您身上没有经验冻结丹效果,无须使用此丹药!");
				} else {
					if (effect1 != null) {
						propOwner.delPropEffect(MmochatPropType.经验冻结丹
								.getEffectKey());
						msgMap.put(1, "您使用了经验解冻丹,经验冻结效果已消失!");
					}
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
				}
				break;

			}
			case 还原丹: {
				MmochatPropEffect effect1 = propOwner.getPropEffects().get(
						MmochatPropType.驱魔符.getEffectKey());
				MmochatPropEffect effect2 = propOwner.getPropEffects().get(
						MmochatPropType.龙涎香.getEffectKey());
				if (effect1 == null && effect2 == null) {
					msgMap.put(0, "您身上没有驱魔符或龙涎香效果,无须使用此丹药!");
				} else {
					if (effect1 != null) {
						propOwner.delPropEffect(MmochatPropType.驱魔符
								.getEffectKey());
						msgMap.put(1, "您使用了还原丹,驱魔符效果已消失!");
					}
					if (effect2 != null) {
						propOwner.delPropEffect(MmochatPropType.龙涎香
								.getEffectKey());
						msgMap.put(1, "您使用了还原丹,龙涎香效果已消失!");
					}
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					// 下发更新驱魔香效果
					Mmochat_1_23S avoidPack = new Mmochat_1_23S();
					avoidPack.setMe(propOwner);
					MmochatUtil.sendCommonPack(propOwner, avoidPack);
				}
				break;
			}
			case 光环还原丹: {
				MmochatPropEffect effect1 = propOwner.getPropEffects().get(
						MmochatPropType.武神光环.getEffectKey());
				MmochatPropEffect effect2 = propOwner.getPropEffects().get(
						MmochatPropType.风神护体.getEffectKey());
				if (effect1 == null && effect2 == null) {
					msgMap.put(0, "您身上没有任何光环效果,无须使用此丹药!");
				} else {
					if (effect1 != null) {
						propOwner.delPropEffect(MmochatPropType.武神光环
								.getEffectKey());
					}
					if (effect2 != null) {
						propOwner.delPropEffect(MmochatPropType.风神护体
								.getEffectKey());
					}
					msgMap.put(1, "您使用了光环还原丹,光环效果已消失!");
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
				}
				break;
			}
			case 仙枝: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;

					int daoAward = 0;
					if (MmochatUtil.isInPercent(5)) {
						daoAward = 1000;
					} else {
						daoAward = MmochatUtil.getRandomValue(100, 500);
					}
					// 刷道比赛
					MmochatPropService.dealDaoActivity(me, daoAward);

					int dao = MmochatBattleService.getRealDao(me, daoAward);
					me.addDao(dao);

					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}

					String info;
					if (dao == daoAward) {
						info = "您获得了" + dao + "天道行!";
					} else {
						info = prop.getPropType().toString() + "中含有" + daoAward
								+ "天道行，但因为您当前道行高于该等级的标准道行，所以您实际获得了" + dao
								+ "天道行!";
					}

					msgMap.put(1, info);
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;
			}
			case 经验丹:
			case 经验果: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;
					MmochatDailyActivity activity;
					Date now = new Date();
					Date lastDate; // 上次参加活动日期

					if (me.getLevel() < prop.getMinUseLevelOfProp()
							|| me.getLevel() > prop.getMaxUseLevelOfProp()) {
						msgMap.put(0, "您的等级无法使用此道具!");
						return msgMap;
					}

					synchronized (propOwner) {
						activity = propOwner.getDailyActivities().get(
								MmochatDailyActivityType.使用经验道具);
						if (activity == null) {
							// 第一次参加此活动
							activity = new MmochatDailyActivity();
							activity.setType(MmochatDailyActivityType.使用经验道具);
							propOwner.addDailyActivity(activity);
						}
						lastDate = new Date(activity.getLastTime());

						if (now.getDate() == lastDate.getDate()
								&& now.getMonth() == lastDate.getMonth()
								&& now.getYear() == lastDate.getYear()) {
							// 今天参加过此活动
							if (activity.getDailyTimes() >= activity.getType()
									.getMaxDailyTimes()) {
								msgMap.put(0, "您今天"
										+ MmochatUtil.wrapColor(
												MmochatPropType.经验丹.toString(),
												Color.green)
										+ "或"
										+ MmochatUtil.wrapColor(
												MmochatPropType.经验果.toString(),
												Color.green)
										+ "的使用次数已满"
										+ activity.getType().getMaxDailyTimes()
										+ "次，不能再使用"
										+ MmochatUtil.wrapColor(
												MmochatPropType.经验丹.toString(),
												Color.green)
										+ "或"
										+ MmochatUtil.wrapColor(
												MmochatPropType.经验果.toString(),
												Color.green) + "!");
								return msgMap;
							} else {
								activity.addDailyTimes(1);
							}
						} else {
							// 今天没有参加过此活动
							activity.setLastTime(now.getTime());
							activity.setDailyTimes(1);
						}
					}

					boolean isUpLevel = me.addExp(prop
							.getExpAmountOfPropForPlayer());

					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}

					String info = "您获得了" + prop.getExpAmountOfPropForPlayer()
							+ "点经验!";
					if (isUpLevel) {
						info += "恭喜您升级了!";
					}

					Mmochat_1_7S pack = new Mmochat_1_7S();
					pack.setMe(me);
					pack.setRoleUplevel(isUpLevel);
					MmochatUtil.sendCommonPack(me, pack);

					msgMap.put(1, info);
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;
			}
			case 道行丹:
			case 道行果: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;
					MmochatDailyActivity activity;
					Date now = new Date();
					Date lastDate; // 上次参加活动日期

					synchronized (propOwner) {
						activity = propOwner.getDailyActivities().get(
								MmochatDailyActivityType.使用道行道具);
						if (activity == null) {
							// 第一次参加此活动
							activity = new MmochatDailyActivity();
							activity.setType(MmochatDailyActivityType.使用道行道具);
							propOwner.addDailyActivity(activity);
						}
						lastDate = new Date(activity.getLastTime());

						if (now.getDate() == lastDate.getDate()
								&& now.getMonth() == lastDate.getMonth()
								&& now.getYear() == lastDate.getYear()) {
							// 今天参加过此活动
							if (activity.getDailyTimes() >= activity.getType()
									.getMaxDailyTimes()) {
								msgMap.put(0, "您今天"
										+ MmochatUtil.wrapColor(
												MmochatPropType.道行丹.toString(),
												Color.green)
										+ "或"
										+ MmochatUtil.wrapColor(
												MmochatPropType.道行果.toString(),
												Color.green)
										+ "的使用次数已满"
										+ activity.getType().getMaxDailyTimes()
										+ "次，不能再使用"
										+ MmochatUtil.wrapColor(
												MmochatPropType.道行丹.toString(),
												Color.green)
										+ "或"
										+ MmochatUtil.wrapColor(
												MmochatPropType.道行果.toString(),
												Color.green) + "!");
								return msgMap;
							} else {
								activity.addDailyTimes(1);
							}
						} else {
							// 今天没有参加过此活动
							activity.setLastTime(now.getTime());
							activity.setDailyTimes(1);
						}
					}

					// 刷道比赛
					MmochatPropService.dealDaoActivity(me, prop
							.getDaoAmountOfPropForPlayer());

					int dao = MmochatBattleService.getRealDao(me, prop
							.getDaoAmountOfPropForPlayer());
					me.addDao(dao);

					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}

					String info;
					if (dao == prop.getDaoAmountOfPropForPlayer()) {
						info = "您获得了" + dao + "天道行!";
					} else {
						info = prop.getPropType().toString() + "中含有"
								+ prop.getDaoAmountOfPropForPlayer()
								+ "天道行，但因为您当前道行高于该等级的标准道行，所以您实际获得了" + dao
								+ "天道行!";
					}

					msgMap.put(1, info);
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;
			}
			case 宠物经验丹:
			case 宠物经验果: {
				if (propUser instanceof MmochatPet) {
					MmochatPet pet = (MmochatPet) propUser;
					if (pet.getBorrowFromRoleId() != null) {
						msgMap.put(0, "这个宠物是向他人借来的，无法使用此道具!");
						return msgMap;
					}
					MmochatDailyActivity activity;
					Date now = new Date();
					Date lastDate; // 上次参加活动日期

					if (pet.getLevel() < prop.getMinUseLevelOfProp()
							|| pet.getLevel() > prop.getMaxUseLevelOfProp()) {
						msgMap.put(0, "您的宠物的等级无法使用此道具!");
						return msgMap;
					}

					synchronized (propOwner) {
						activity = propOwner.getDailyActivities().get(
								MmochatDailyActivityType.使用宠物经验道具);
						if (activity == null) {
							// 第一次参加此活动
							activity = new MmochatDailyActivity();
							activity.setType(MmochatDailyActivityType.使用宠物经验道具);
							propOwner.addDailyActivity(activity);
						}
						lastDate = new Date(activity.getLastTime());

						if (now.getDate() == lastDate.getDate()
								&& now.getMonth() == lastDate.getMonth()
								&& now.getYear() == lastDate.getYear()) {
							// 今天参加过此活动
							if (activity.getDailyTimes() >= activity.getType()
									.getMaxDailyTimes()) {
								msgMap.put(0, "您今天"
										+ MmochatUtil.wrapColor(
												MmochatPropType.宠物经验丹
														.toString(),
												Color.green)
										+ "或"
										+ MmochatUtil.wrapColor(
												MmochatPropType.宠物经验果
														.toString(),
												Color.green)
										+ "的使用次数已满"
										+ activity.getType().getMaxDailyTimes()
										+ "次，不能再使用"
										+ MmochatUtil.wrapColor(
												MmochatPropType.宠物经验丹
														.toString(),
												Color.green)
										+ "或"
										+ MmochatUtil.wrapColor(
												MmochatPropType.宠物经验果
														.toString(),
												Color.green) + "!");
								return msgMap;
							} else {
								activity.addDailyTimes(1);
							}
						} else {
							// 今天没有参加过此活动
							activity.setLastTime(now.getTime());
							activity.setDailyTimes(1);
						}
					}

					boolean isUpLevel = pet.addExp(propOwner, prop
							.getExpAmountOfPropForPet());

					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}

					String info = "您的宠物获得了" + prop.getExpAmountOfPropForPet()
							+ "点经验!";
					if (isUpLevel) {
						info += "恭喜您的宠物升级了!";
					}

					Mmochat_1_7S pack = new Mmochat_1_7S();
					pack.setMe(propOwner);
					pack.setRoleUplevel(false);
					MmochatUtil.sendCommonPack(propOwner, pack);

					msgMap.put(1, info);
				} else {
					msgMap.put(0, "此道具只能给宠物使用!请打开宠物信息面板,点击<喂养>使用!");
					return msgMap;
				}
				break;
			}
			case 宠物武学丹:
			case 宠物武学果: {
				if (propUser instanceof MmochatPet) {
					MmochatPet pet = (MmochatPet) propUser;
					if (pet.getBorrowFromRoleId() != null) {
						msgMap.put(0, "这个宠物是向他人借来的，无法使用此道具!");
						return msgMap;
					}
					MmochatDailyActivity activity;
					Date now = new Date();
					Date lastDate; // 上次参加活动日期

					synchronized (propOwner) {
						activity = propOwner.getDailyActivities().get(
								MmochatDailyActivityType.使用宠物武学道具);
						if (activity == null) {
							// 第一次参加此活动
							activity = new MmochatDailyActivity();
							activity.setType(MmochatDailyActivityType.使用宠物武学道具);
							propOwner.addDailyActivity(activity);
						}
						lastDate = new Date(activity.getLastTime());

						if (now.getDate() == lastDate.getDate()
								&& now.getMonth() == lastDate.getMonth()
								&& now.getYear() == lastDate.getYear()) {
							// 今天参加过此活动
							if (activity.getDailyTimes() >= activity.getType()
									.getMaxDailyTimes()) {
								msgMap.put(0, "您今天"
										+ MmochatUtil.wrapColor(
												MmochatPropType.宠物武学丹
														.toString(),
												Color.green)
										+ "或"
										+ MmochatUtil.wrapColor(
												MmochatPropType.宠物武学果
														.toString(),
												Color.green)
										+ "的使用次数已满"
										+ activity.getType().getMaxDailyTimes()
										+ "次，不能再使用"
										+ MmochatUtil.wrapColor(
												MmochatPropType.宠物武学丹
														.toString(),
												Color.green)
										+ "或"
										+ MmochatUtil.wrapColor(
												MmochatPropType.宠物武学果
														.toString(),
												Color.green) + "!");
								return msgMap;
							} else {
								activity.addDailyTimes(1);
							}
						} else {
							// 今天没有参加过此活动
							activity.setLastTime(now.getTime());
							activity.setDailyTimes(1);
						}
					}

					int dao = MmochatBattleService.getRealDao(pet, prop
							.getDaoAmountOfPropForPet());
					pet.addDao(dao);

					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}

					String info;
					if (dao == prop.getDaoAmountOfPropForPet()) {
						info = "您的宠物获得了" + dao + "点武学!";
					} else {
						info = prop.getPropType().toString() + "中含有"
								+ prop.getDaoAmountOfPropForPet()
								+ "点武学，但因为您的宠物当前武学高于该等级的标准武学，所以您的宠物实际获得了" + dao
								+ "点武学!";
					}

					msgMap.put(1, info);
				} else {
					msgMap.put(0, "此道具只能给宠物使用!请打开宠物信息面板,点击<喂养>使用!");
					return msgMap;
				}
				break;
			}
			case 成长丹: {
				if (propUser instanceof MmochatPet) {
					MmochatPet pet = (MmochatPet) propUser;
					if (pet.getBorrowFromRoleId() != null) {
						msgMap.put(0, "这个宠物是向他人借来的，无法使用此道具!");
						return msgMap;
					}
					if (pet.getOwnerState() != MmochatObjOwnerState.未认主) {
						msgMap.put(0, "此道具只能给未认主的宠物使用!");
						return msgMap;
					}
					// if (pet.getPetType() != MmochatPetType.野生
					// && pet.getPetType() != MmochatPetType.宝宝) {
					// msgMap.put(0, "此道具只能给野生或宝宝类型的宠物使用!");
					// return msgMap;
					// }
					MmochatPetService.createPetFromPet(pet);
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
				} else {
					msgMap.put(0, "此道具只能给宠物使用!请打开宠物信息面板,点击<喂养>使用!");
					return msgMap;
				}
				break;
			}
			case 超级成长丹: {
				if (propUser instanceof MmochatPet) {
					MmochatPet pet = (MmochatPet) propUser;
					if (pet.getBorrowFromRoleId() != null) {
						msgMap.put(0, "这个宠物是向他人借来的，无法使用此道具!");
						return msgMap;
					}
					if (pet.getPetType() == MmochatPetType.野生) {
						msgMap.put(0, "此道具不能给野生类型的宠物使用!");
						return msgMap;
					}
					MmochatPetService.resetPetProtential(pet);
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
				} else {
					msgMap.put(0, "此道具只能给宠物使用!请打开宠物信息面板,点击<喂养>使用!");
					return msgMap;
				}
				break;
			}
			case 血量成长丹:
			case 物攻成长丹:
			case 法攻成长丹:
			case 速度成长丹:
			case 物防成长丹:
			case 法防成长丹: {
				// type:0:物攻；1:法攻；2:速度；3:血量；4:物防；5:法防
				if (propUser instanceof MmochatPet) {
					MmochatPet pet = (MmochatPet) propUser;
					if (pet.getBorrowFromRoleId() != null) {
						msgMap.put(0, "这个宠物是向他人借来的，无法使用此道具!");
						return msgMap;
					}
					if (pet.getPetType() == MmochatPetType.野生) {
						msgMap.put(0, "此道具不能给野生类型的宠物使用!");
						return msgMap;
					}
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					switch (prop.getPropType()) {
					case 血量成长丹:
						MmochatPetService.resetPetProtential(pet, 3);
						break;
					case 物攻成长丹:
						MmochatPetService.resetPetProtential(pet, 0);
						break;
					case 法攻成长丹:
						MmochatPetService.resetPetProtential(pet, 1);
						break;
					case 速度成长丹:
						MmochatPetService.resetPetProtential(pet, 2);
						break;
					case 物防成长丹:
						MmochatPetService.resetPetProtential(pet, 4);
						break;
					case 法防成长丹:
						MmochatPetService.resetPetProtential(pet, 5);
						break;
					default:
						break;
					}
				} else {
					msgMap.put(0, "此道具只能给宠物使用!请打开宠物信息面板,点击<喂养>使用!");
					return msgMap;
				}
				break;
			}
			case 轮回水: {
				if (propUser instanceof MmochatPet) {
					MmochatPet pet = (MmochatPet) propUser;
					if (pet.getBorrowFromRoleId() != null) {
						msgMap.put(0, "这个宠物是向他人借来的，无法使用此道具!");
						return msgMap;
					}
					if (pet.getPetType() == MmochatPetType.野生) {
						msgMap.put(0, "此道具不能给野生类型的宠物使用!");
						return msgMap;
					}
					int delBloodPoint = Math.min(2, pet.getBlood_point()
							- pet.getLevel());
					int delSpritPoint = Math.min(2, pet.getSprit_point()
							- pet.getLevel());
					int delAttackPoint = Math.min(2, pet.getAttack_point()
							- pet.getLevel());
					int delSpeedPoint = Math.min(2, pet.getSpeed_point()
							- pet.getLevel());
					if (delBloodPoint == 0 && delSpritPoint == 0
							&& delAttackPoint == 0 && delSpeedPoint == 0) {
						msgMap.put(0, "此宠物没有可洗的属性点!");
						return msgMap;
					}
					pet.delBlood_point(delBloodPoint);
					pet.delSprit_point(delSpritPoint);
					pet.delAttack_point(delAttackPoint);
					pet.delSpeed_point(delSpeedPoint);
					pet.addSpace_point(delBloodPoint + delSpritPoint
							+ delAttackPoint + delSpeedPoint);
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
				} else {
					msgMap.put(0, "此道具只能给宠物使用!请打开宠物信息面板,点击<喂养>使用!");
					return msgMap;
				}
				break;
			}
			case 超级轮回水: {
				if (propUser instanceof MmochatPet) {
					MmochatPet pet = (MmochatPet) propUser;
					if (pet.getBorrowFromRoleId() != null) {
						msgMap.put(0, "这个宠物是向他人借来的，无法使用此道具!");
						return msgMap;
					}
					if (pet.getPetType() == MmochatPetType.野生) {
						msgMap.put(0, "此道具不能给野生类型的宠物使用!");
						return msgMap;
					}
					int delBloodPoint = pet.getBlood_point() - pet.getLevel();
					int delSpritPoint = pet.getSprit_point() - pet.getLevel();
					int delAttackPoint = pet.getAttack_point() - pet.getLevel();
					int delSpeedPoint = pet.getSpeed_point() - pet.getLevel();

					if (delBloodPoint == 0 && delSpritPoint == 0
							&& delAttackPoint == 0 && delSpeedPoint == 0) {
						msgMap.put(0, "此宠物没有可洗的属性点!");
						return msgMap;
					}
					pet.delBlood_point(delBloodPoint);
					pet.delSprit_point(delSpritPoint);
					pet.delAttack_point(delAttackPoint);
					pet.delSpeed_point(delSpeedPoint);
					pet.addSpace_point(delBloodPoint + delSpritPoint
							+ delAttackPoint + delSpeedPoint);
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
				} else {
					msgMap.put(0, "此道具只能给宠物使用!请打开宠物信息面板,点击<喂养>使用!");
					return msgMap;
				}
				break;
			}
			case 大法玲珑:
			case 中法玲珑:
			case 小法玲珑: {
				int spritNeed = 0;
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer user = (MmochatPlayer) propUser;
					spritNeed = user.getTotalSprit() - user.getCurSprit();
					if (spritNeed > 0) {
						spritNeed = Math.min(spritNeed,
								MmochatConstant.maxSpritPropCanAdd);
						spritNeed = Math
								.min(spritNeed, prop.getCurPropAmount());
						user.addCurSprit(spritNeed);
						prop.delAmount(spritNeed);
					}
				} else if (propUser instanceof MmochatPet) {
					MmochatPet pet = (MmochatPet) propUser;
					if (pet != null) {
						spritNeed = pet.getTotalSprit() - pet.getCurSprit();
						if (spritNeed > 0) {
							spritNeed = Math.min(spritNeed,
									MmochatConstant.maxSpritPropCanAdd);
							spritNeed = Math.min(spritNeed, prop
									.getCurPropAmount());
							pet.addCurSprit(spritNeed);
							prop.delAmount(spritNeed);
						}
					}
				}
				if (spritNeed <= 0) {
					return msgMap;
				}
				addPropCost = false;
				if (prop.getCurPropAmount() <= 0) {
					grid.setObject(null);
					msgMap.put(1, "法玲珑已经用光!");
					MmochatStatisticsService.addPropCost(propType, 1);
				}
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer user = (MmochatPlayer) propUser;
					if (!user.isInBattle()) {
						Mmochat_1_7S pack = new Mmochat_1_7S();
						pack.setMe(user);
						MmochatUtil.sendCommonPack(user, pack);
					}
				} else {
					if (!propOwner.isInBattle()) {
						Mmochat_1_7S pack = new Mmochat_1_7S();
						pack.setMe(propOwner);
						MmochatUtil.sendCommonPack(propOwner, pack);
					}
				}
				break;
			}
			case 大血玲珑:
			case 中血玲珑:
			case 小血玲珑:
			case 大血瓶:
			case 中血瓶:
			case 小血瓶: {
				int bloodNeed = 0;
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer user = (MmochatPlayer) propUser;
					bloodNeed = user.getTotalBlood() - user.getCurBlood();
					if (bloodNeed > 0) {
						bloodNeed = Math.min(bloodNeed,
								MmochatConstant.maxBloodPropCanAddForPVE);
						bloodNeed = Math
								.min(bloodNeed, prop.getCurPropAmount());
						user.addCurBlood(bloodNeed);
						prop.delAmount(bloodNeed);
					}
				} else if (propUser instanceof MmochatPet) {
					MmochatPet pet = (MmochatPet) propUser;
					bloodNeed = 0;
					if (pet != null) {
						bloodNeed = pet.getTotalBlood() - pet.getCurBlood();
						if (bloodNeed > 0) {
							bloodNeed = Math.min(bloodNeed,
									MmochatConstant.maxBloodPropCanAddForPVE);
							bloodNeed = Math.min(bloodNeed, prop
									.getCurPropAmount());
							pet.addCurBlood(bloodNeed);
							prop.delAmount(bloodNeed);
						}
					}
				}
				if (bloodNeed <= 0) {
					return msgMap;
				}
				addPropCost = false;
				if (prop.getCurPropAmount() <= 0) {
					grid.setObject(null);
					msgMap.put(1, "此道具已经用光!");
					MmochatStatisticsService.addPropCost(propType, 1);
				}
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer user = (MmochatPlayer) propUser;
					if (!user.isInBattle()) {
						Mmochat_1_7S pack = new Mmochat_1_7S();
						pack.setMe(user);
						MmochatUtil.sendCommonPack(user, pack);
					}
				} else {
					if (!propOwner.isInBattle()) {
						Mmochat_1_7S pack = new Mmochat_1_7S();
						pack.setMe(propOwner);
						MmochatUtil.sendCommonPack(propOwner, pack);
					}
				}
				break;
			}
			case 江湖名号: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;
					CreateEditBoxTLV edit = new CreateEditBoxTLV();
					edit.setTitle("请输入新昵称");
					edit.setLeftName("确定");
					edit.setRightName("取消");
					edit.setContentLenMax(5);
					edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
					edit.setInputType(CreateEditBoxTLV.INPUT_ANY << 4);
					edit.addLeftTLV(new AddEditBoxTLV());
					edit.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
					edit.addLeftTLV(new SendDataTLV(MmochatConstant
							.getClientModuleId(),
							MmochatMain.getModuleInstID(),
							MmochatConstant.MSGCODE_MMOCHAT_C_13_7,
							(int) gridId));
					ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
					wait.setShowCancel(false);
					edit.addLeftTLV(wait);
					msgMap.put(2, (TLVStructure) edit);
					addPropCost = false;
					return msgMap;
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
			}
			case 锦囊: {
				if (propUser instanceof MmochatPlayer) {
					if (!propOwner.hasEnoughPackageSpace(1)) {
						msgMap.put(0, "您的包裹已满,请先清理出一个空位!");
						return msgMap;
					}
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					MmochatPlayer me = (MmochatPlayer) propUser;
					// propType->机率
					Object propRate[][] = { { MmochatPropType.传送符, 0.02 },
							{ MmochatPropType.龙涎香, 0.02 },
							{ MmochatPropType.中血池, 0.02 },
							{ MmochatPropType.小血池, 0.03 },
							{ MmochatPropType.中法池, 0.02 },
							{ MmochatPropType.小法池, 0.03 },
							{ MmochatPropType.中血玲珑, 0.02 },
							{ MmochatPropType.小血玲珑, 0.03 },
							{ MmochatPropType.中法玲珑, 0.02 },
							{ MmochatPropType.小法玲珑, 0.03 },
							{ MmochatPropType.混沌石, 0.01 },
							{ MmochatPropType.超级改造石, 0.01 },
							{ MmochatPropType.喇叭, 0.04 },
							{ MmochatPropType.成长丹, 0.02 },
							{ MmochatPropType.超级成长丹, 0.01 },
							{ MmochatPropType.轮回水, 0.05 },
							{ MmochatPropType.迟滞水, 0.02 },
							{ MmochatPropType.八卦令, 0.02 },
							{ MmochatPropType.银联卡, 0.02 },
							{ MmochatPropType.赎罪牌, 0.01 },
							{ MmochatPropType.后悔药, 0.05 },
							{ MmochatPropType.防冻剂, 0.05 },
							{ MmochatPropType.镇定剂, 0.05 },
							{ MmochatPropType.虚无水, 0.05 } };
					double rate = Math.random();
					double curRate = 0;
					boolean hit = false;
					for (int i = 0; i < propRate.length; i++) {
						curRate += (Double) propRate[i][1];
						if (curRate > rate) {
							// 命中道具
							MmochatProp newProp = new MmochatProp(
									(MmochatPropType) propRate[i][0]);
							me.addObjectToPackage(newProp);
							msgMap.put(1, "您打开锦囊获得了一个"
									+ newProp.getType().toString() + "!");
							hit = true;
							break;
						}
					}
					if (hit) {
						break;
					}
					// 10000元宝奖励
					curRate += 0.002;
					if (curRate > rate) {
						// 命中元宝
						me.addBig_money(10000);
						MmochatStatisticsService.addBigMoneyEarn(
								MmochatBigMoneyEarnType.锦囊, 10000);
						msgMap.put(1, "恭喜!!!您打开锦囊获得了超级大奖10000元宝!");
						systemMsg = MmochatUtil.wrapColor(me.getName(),
								Color.yellow)
								+ "鸿运当头,打开锦囊喜得"
								+ MmochatUtil
										.wrapColor("10000元宝", Color.yellow)
								+ "!";
						break;
					}
					// 战绩100点
					curRate += 0.1;
					if (curRate > rate) {
						// 命中战绩
						me.addZhanji(100);
						msgMap.put(1, "您打开锦囊获得了100点战绩");
						break;
					}
					// 道行100天
					curRate += 0.1;
					if (curRate > rate) {
						// 命中道行
						// 刷道比赛
						MmochatPropService.dealDaoActivity(me, 100);

						int trueDao = MmochatBattleService.getRealDao(me, 100);
						me.addDao(trueDao);
						msgMap.put(1, "您打开锦囊获得了" + trueDao + "天道行");
						break;
					}
					// 其它的给30000游戏币
					me.addAndUpdateSmall_money(30000);
					MmochatStatisticsService.addSmallMoneyEarn(
							MmochatSmallMoneyEarnType.锦囊, 30000);
					msgMap.put(1, "您打开锦囊获得了" + MmochatUtil.getColorMoney(30000)
							+ "文钱");
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;
			}
			case 后悔药: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;
					int delBloodPoint = Math.min(2, me.getBlood_point()
							- me.getLevel());
					int delSpritPoint = Math.min(2, me.getSprit_point()
							- me.getLevel());
					int delAttackPoint = Math.min(2, me.getAttack_point()
							- me.getLevel());
					int delSpeedPoint = Math.min(2, me.getSpeed_point()
							- me.getLevel());
					if (delBloodPoint == 0 && delSpritPoint == 0
							&& delAttackPoint == 0 && delSpeedPoint == 0) {
						msgMap.put(0, "您没有可洗的属性点!");
						return msgMap;
					}
					me.delBlood_point(delBloodPoint);
					me.delSprit_point(delSpritPoint);
					me.delAttack_point(delAttackPoint);
					me.delSpeed_point(delSpeedPoint);
					me.addSpace_point(delBloodPoint + delSpritPoint
							+ delAttackPoint + delSpeedPoint);
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					// 设置气血,法力
					me.addCurBlood(0);
					me.addCurSprit(0);
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;
			}
			case 超级后悔药: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;
					int delBloodPoint = me.getBlood_point() - me.getLevel();
					int delSpritPoint = me.getSprit_point() - me.getLevel();
					int delAttackPoint = me.getAttack_point() - me.getLevel();
					int delSpeedPoint = me.getSpeed_point() - me.getLevel();

					if (delBloodPoint == 0 && delSpritPoint == 0
							&& delAttackPoint == 0 && delSpeedPoint == 0) {
						msgMap.put(0, "您没有可洗的属性点!");
						return msgMap;
					}
					me.delBlood_point(delBloodPoint);
					me.delSprit_point(delSpritPoint);
					me.delAttack_point(delAttackPoint);
					me.delSpeed_point(delSpeedPoint);
					me.addSpace_point(delBloodPoint + delSpritPoint
							+ delAttackPoint + delSpeedPoint);
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					// 设置气血,法力
					me.addCurBlood(0);
					me.addCurSprit(0);
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;
			}
			case 洗髓丹: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;
					int delBloodPoint = Math.min(1, me.getBlood_gift_point());
					int delSpritPoint = Math.min(1, me.getSprit_gift_point());
					int delAttackPoint = Math.min(1, me.getAttack_gift_point());
					int delSpeedPoint = Math.min(1, me.getSpeed_gift_point());
					int delDefendPoint = Math.min(1, me.getDefend_gift_point());
					if (delDefendPoint == 0 && delBloodPoint == 0
							&& delSpritPoint == 0 && delAttackPoint == 0
							&& delSpeedPoint == 0) {
						msgMap.put(0, "您没有可洗的天赋点!");
						return msgMap;
					}
					me.delBlood_gift_point(delBloodPoint);
					me.delDefend_gift_point(delDefendPoint);
					me.delSprit_gift_point(delSpritPoint);
					me.delAttack_gift_point(delAttackPoint);
					me.delSpeed_gift_point(delSpeedPoint);
					me.addSpace_gift_point(delBloodPoint + delSpritPoint
							+ delAttackPoint + delSpeedPoint + delDefendPoint);
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					// 设置气血,法力
					me.addCurBlood(0);
					me.addCurSprit(0);
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;
			}
			case 超级洗髓丹: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;
					int delBloodPoint = me.getBlood_gift_point();
					int delSpritPoint = me.getSprit_gift_point();
					int delAttackPoint = me.getAttack_gift_point();
					int delSpeedPoint = me.getSpeed_gift_point();
					int delDefendPoint = me.getDefend_gift_point();
					if (delDefendPoint == 0 && delBloodPoint == 0
							&& delSpritPoint == 0 && delAttackPoint == 0
							&& delSpeedPoint == 0) {
						msgMap.put(0, "您没有可洗的天赋点!");
						return msgMap;
					}
					me.delBlood_gift_point(delBloodPoint);
					me.delDefend_gift_point(delDefendPoint);
					me.delSprit_gift_point(delSpritPoint);
					me.delAttack_gift_point(delAttackPoint);
					me.delSpeed_gift_point(delSpeedPoint);
					me.addSpace_gift_point(delBloodPoint + delSpritPoint
							+ delAttackPoint + delSpeedPoint + delDefendPoint);
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					// 设置气血,法力
					me.addCurBlood(0);
					me.addCurSprit(0);
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;
			}
			case 银联卡: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;
					if (MmochatNpcService.checkStorePwd(me)) {
						msgMap.put(3, true);
						return msgMap;
					}
					CreateTlvWin tlv = new CreateTlvWin();
					tlv.setWinType(WinType.List);
					tlv.setTitle("远程钱庄");
					tlv.setRightName("返回");
					tlv.setLeftName("确定");
					tlv.setWinHeight(208);
					tlv.addRightTLV(new CloseWinTLV());
					tlv.addItemEvent("存放物品", new ClearDataTLV(),
							new AddDataTLV((int) 0));
					tlv.addItemEvent("取回物品", new ClearDataTLV(),
							new AddDataTLV((int) 1));
					tlv.addItemEvent("存放宠物", new ClearDataTLV(),
							new AddDataTLV((int) 2));
					tlv.addItemEvent("取回宠物", new ClearDataTLV(),
							new AddDataTLV((int) 3));
					tlv.addLeftTLV(new SendDataTLV(MmochatConstant
							.getClientModuleId(),
							MmochatMain.getModuleInstID(),
							MmochatConstant.MSGCODE_MMOCHAT_C_13_8, (int) me
									.getRoleId()));
					tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());
					msgMap.put(2, (TLVStructure) tlv);
					addPropCost = false;
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
							MmochatStatisticsService.addPropCost(propType, 1);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
							MmochatStatisticsService.addPropCost(propType, 1);
						}
					}
					break;
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
			}
			case 迟滞水: {
				if (propUser instanceof MmochatPet) {
					MmochatPet pet = (MmochatPet) propUser;
					if (pet.getBorrowFromRoleId() != null) {
						msgMap.put(0, "这个宠物是向他人借来的，无法使用此道具!");
						return msgMap;
					}
					if (pet.getSpeed_protential() <= 0) {
						msgMap.put(0, "此宠物速度成长已达下限值0,无法再降!");
						return msgMap;
					}
					pet.delSpeed_protential(10);
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					msgMap.put(1, "您的" + pet.getName() + "速度成长降到了"
							+ pet.getSpeed_protential() + "!");
				} else {
					msgMap.put(0, "此道具只能给宠物使用!请打开宠物信息面板,点击<喂养>使用!");
					return msgMap;
				}
				break;
			}
			case 防冻剂: {
				if (propUser instanceof MmochatPet) {
					MmochatPet pet = (MmochatPet) propUser;
					if (pet.getBorrowFromRoleId() != null) {
						msgMap.put(0, "这个宠物是向他人借来的，无法使用此道具!");
						return msgMap;
					}
					if (pet.getAntiFreeze() >= MmochatConstant.maxPetAntiLimit) {
						msgMap
								.put(0, "此宠物抗冰冻能力已达上限值"
										+ MmochatConstant.maxPetAntiLimit
										+ ",无法使用此道具!");
						return msgMap;
					}
					pet.addAntiFreeze(2);
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					msgMap.put(1, "您的" + pet.getName() + "抗冰冻能力达到"
							+ pet.getAntiFreeze() + "!");
				} else {
					msgMap.put(0, "此道具只能给宠物使用!请打开宠物信息面板,点击<喂养>使用!");
					return msgMap;
				}
				break;
			}
			case 镇定剂: {
				if (propUser instanceof MmochatPet) {
					MmochatPet pet = (MmochatPet) propUser;
					if (pet.getBorrowFromRoleId() != null) {
						msgMap.put(0, "这个宠物是向他人借来的，无法使用此道具!");
						return msgMap;
					}
					if (pet.getAntiConfuse() >= MmochatConstant.maxPetAntiLimit) {
						msgMap
								.put(0, "此宠物抗混乱能力已达上限值"
										+ MmochatConstant.maxPetAntiLimit
										+ ",无法使用此道具!");
						return msgMap;
					}
					pet.addAntiConfuse(2);
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					msgMap.put(1, "您的" + pet.getName() + "抗混乱能力达到"
							+ pet.getAntiConfuse() + "!");
				} else {
					msgMap.put(0, "此道具只能给宠物使用!请打开宠物信息面板,点击<喂养>使用!");
					return msgMap;
				}
				break;
			}
			case 虚无水: {
				if (propUser instanceof MmochatPet) {
					MmochatPet pet = (MmochatPet) propUser;
					if (pet.getBorrowFromRoleId() != null) {
						msgMap.put(0, "这个宠物是向他人借来的，无法使用此道具!");
						return msgMap;
					}
					if (pet.getAntiSeal() >= MmochatConstant.maxPetAntiLimit) {
						msgMap
								.put(0, "此宠物抗封印能力已达上限值"
										+ MmochatConstant.maxPetAntiLimit
										+ ",无法使用此道具!");
						return msgMap;
					}
					pet.addAntiSeal(2);
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					msgMap.put(1, "您的" + pet.getName() + "抗封印能力达到"
							+ pet.getAntiSeal() + "!");
				} else {
					msgMap.put(0, "此道具只能给宠物使用!请打开宠物信息面板,点击<喂养>使用!");
					return msgMap;
				}
				break;
			}
			case 金钱袋: {
				// 生成大约10W的金钱
				// 1%：100W, 5%: 20W, 94%: 8W(6,7,8,9,10)
				if (prop.isCanOverlap()) {
					prop.delOverlapNum(1);
					if (prop.getOverlapNum() <= 0) {
						grid.setObject(null);
					}
				} else {
					prop.delAmount(1);
					if (prop.getCurPropAmount() <= 0) {
						grid.setObject(null);
					}
				}
				int percent = MmochatUtil.getRandomValue(100);
				int money = 0;
				if (percent == 0) {
					// 100W
					money = 1000000;
					String info = MmochatUtil.wrapColor(propOwner.getName(),
							Color.green);
					info += "鸿运当头，打开金钱袋时意外得发现了"
							+ MmochatUtil.getColorMoney(money) + "文钱";
					MmochatChatService.sendSystemMsg(info);
				} else if (percent < 6) {
					// 20W
					money = 200000;
				} else {
					// 8W(6,7,8,9,10)
					money = MmochatUtil.getRandomValue(5) * 10000 + 60000;
				}
				propOwner.addAndUpdateSmall_money(money);
				MmochatStatisticsService.addSmallMoneyEarn(
						MmochatSmallMoneyEarnType.金钱袋, money);
				msgMap.put(1, "您打开金钱袋，获得了" + MmochatUtil.getColorMoney(money)
						+ "文钱!");
				break;
			}
			case 藏宝图: {
				// 检查已有任务
				MmochatTask myTask = propOwner
						.getTaskByType(MmochatTaskType.寻宝任务);
				if (myTask != null) {
					// 删除寻宝任务
					propOwner.getTasks().remove(myTask.getTaskId());

					Mmochat_4_12S taskPack = new Mmochat_4_12S();
					taskPack.setTaskId(myTask.getTaskId());
					MmochatUtil.sendCommonPack(propOwner, taskPack);
				}

				// 生成藏宝地点
				int[] maps;
				int levelRange = MmochatUtil.getRandomValue(propOwner
						.getLevel());
				if (levelRange < 20) {
					maps = new int[] { 1, 23, 10, 11 };
				} else if (levelRange < 40) {
					maps = new int[] { 2, 16, 3 };
				} else if (levelRange < 60) {
					maps = new int[] { 19, 20 };
				} else if (levelRange < 80) {
					maps = new int[] { 13, 14, 8, 9 };
				} else if (levelRange < 100) {
					maps = new int[] { 6, 7, 18 };
				} else {
					maps = new int[] { 15, 21, 17, 22 };
				}
				int index = MmochatUtil.getRandomValue(maps.length);
				int mapId = maps[index];
				MmochatPoint point = MmochatMapService
						.getRandReachablePoint(mapId);
				MmochatMap map = MmochatMapService.getMapByMapId(mapId);
				if (map == null) {
					log.error("藏宝图生成一个未知地点：mapId=" + mapId);
					msgMap.put(0, "服务器忙，请稍候再试");
					return msgMap;
				}
				short x1 = (short) (point.getX() * 24 + Math.random() * 24);
				short y1 = (short) (point.getY() * 24 + Math.random() * 24);

				// 生成寻宝任务
				MmochatTempTask hintTask = new MmochatTempTask(true);
				hintTask.setTaskName("寻宝任务");
				hintTask.setTaskDetail("在"
						+ MmochatUtil.wrapColor(map.getMapName() + "(" + x1
								+ "," + y1 + ")", Color.yellow)
						+ "附近好像藏着什么宝藏,带上锄头到那里去挖挖看吧。"
						+ MmochatUtil.wrapColor(
								"(锄头在杂货店有售。到达指定坐标后打开包裹使用锄头即可。)", Color.green));
				hintTask.setTaskType(MmochatTaskType.寻宝任务);
				hintTask.setTaskState(MmochatTaskStateType.已接);
				hintTask.setTargetMapId(mapId);
				hintTask.setTargetX(x1);
				hintTask.setTargetY(y1);
				propOwner.addTask(hintTask);

				// 下发增加任务
				Mmochat_4_11S pack = new Mmochat_4_11S();
				pack.setActionType(0);
				pack.setMe(propOwner);
				pack.setTask(hintTask);
				MmochatUtil.sendCommonPack(propOwner, pack);

				// 删除宝图
				if (prop.isCanOverlap()) {
					prop.delOverlapNum(1);
					if (prop.getOverlapNum() <= 0) {
						grid.setObject(null);
					}
				} else {
					prop.delAmount(1);
					if (prop.getCurPropAmount() <= 0) {
						grid.setObject(null);
					}
				}

				// 保存任务到数据库
				try {
					MmochatDao.updateRoleTasks(propOwner);
				} catch (Exception e) {
					e.printStackTrace();
				}

				msgMap.put(1, "藏宝图的秘密已经揭开，快按4键查看<寻宝任务>，根据里面的提示去找宝藏吧!");
				break;
			}
			case 锄头: {
				// 检查已有任务
				MmochatTask myTask = propOwner
						.getTaskByType(MmochatTaskType.寻宝任务);
				if (myTask == null) {
					msgMap.put(0, "没事不要乱挖，破坏了花花草草就不好了。");
					return msgMap;
				}
				if (!propOwner.hasEnoughPackageSpace(1)) {
					msgMap.put(0, "您的包裹已满,请先清理出一个空位!");
					return msgMap;
				}
				int mapId = myTask.getTargetMapId();
				int treasureX = myTask.getTargetX();
				int treasureY = myTask.getTargetY();
				int curMapId = propOwner.getMapId();
				int x = propOwner.getX();
				int y = propOwner.getY();
				if (curMapId != mapId) {
					msgMap.put(0, "宝藏好像不在这个地图，在这挖是白费力气啊。");
					return msgMap;
				}
				if (Math.abs(treasureX - x) > 60
						|| Math.abs(treasureY - y) > 60) {
					msgMap.put(0, "还没到藏宝点呢，在这挖应该是挖不到东西的。");
					return msgMap;
				}
				// 挖出宝藏
				// 平均价值：30000
				// 0.1%：周卡(888), 9.9%:空图(0), 10%:3个鬼(15000), 5%:10W(5000),
				// 75%:平均5000(3000~7000)
				int percent = MmochatUtil.getRandomValue(1000);
				if (percent == 0) {
					// 周卡
					MmochatProp vip = new MmochatProp(MmochatPropType.会员周卡);
					propOwner.addObjectToPackage(vip);
					String info = MmochatUtil.wrapColor(propOwner.getName(),
							Color.green);
					info += "人品爆发，在挖藏宝图时意外的挖到了一张";
					info += MmochatUtil.wrapColor("会员周卡", Color.yellow);
					info += "!";
					msgMap
							.put(1, "你挖到了一张"
									+ MmochatUtil.wrapColor("会员周卡",
											Color.yellow) + "。");
				} else if (percent < 80) {
					// 空图
					msgMap.put(1, "这里什么也没有，看来这是张假图!");
				} else if (percent < 200) {
					// 放鬼
					// int[] maps;
					// int levelRange = MmochatUtil.getRandomValue(propOwner
					// .getLevel());
					// int ghostLevel = 110;
					// if (levelRange < 20) {
					// maps = new int[] { 1, 23, 10, 11 };
					// ghostLevel = 10;
					// } else if (levelRange < 40) {
					// maps = new int[] { 2, 16, 3 };
					// ghostLevel = 30;
					// } else if (levelRange < 60) {
					// maps = new int[] { 19, 20 };
					// ghostLevel = 50;
					// } else if (levelRange < 80) {
					// maps = new int[] { 13, 14, 8, 9 };
					// ghostLevel = 70;
					// } else if (levelRange < 100) {
					// maps = new int[] { 6, 7, 18 };
					// ghostLevel = 90;
					// } else {
					// maps = new int[] { 15, 21, 17, 22 };
					// ghostLevel = 110;
					// }
					// int index = MmochatUtil.getRandomValue(maps.length);
					// int ghostMapId = maps[index];

					// 鬼怪放到余杭
					int ghostMapId = MmochatConstant.mapId_西岐;
					int ghostLevel = Math.max(propOwner.getLevel() / 10 * 10,
							30);
					MmochatMap map = MmochatMapService
							.getMapByMapId(ghostMapId);
					if (map == null) {
						log.error("藏宝图放鬼，鬼怪生在一个未知地点：mapId=" + ghostMapId);
						msgMap.put(0, "服务器忙，请稍候再试");
						return msgMap;
					}

					// 在此地图生成鬼怪
					for (int i = 0; i < MmochatConstant.ghostNumPerTreasureMap; i++) {
						MmochatPoint ghostPoint = MmochatMapService
								.getRandReachablePoint(ghostMapId);
						if (ghostPoint != null) {
							MmochatTempNpc boss = new MmochatTempNpc(true);
							MmochatNpcService.npcs.put(boss.getNpcId(), boss);
							boss.getFunctionItems().add(MmochatNpcItemType.击杀);
							boss.setLevel(ghostLevel);
							boss.setLifeTime(3600000);
							boss.setLine(propOwner.getLine());
							boss.setName(ghostLevel + "级藏宝图鬼怪");
							boss.setBmpType(MmochatRoleBmpType.动物1);
							boss.setMapId(ghostMapId);
							short x1 = (short) (ghostPoint.getX() * 24 + Math
									.random() * 24);
							short y1 = (short) (ghostPoint.getY() * 24 + Math
									.random() * 24);
							boss.setX(x1);
							boss.setY(y1);

							map.addNpc(boss.getLine(), boss);

							MmochatTask newTask = new MmochatTask();
							newTask.setTaskId(0);
							boss.addTask(newTask);
							MmochatNpcBattle battle = new MmochatNpcBattle();
							newTask.setFinish_need_battles(battle);
							newTask.setTaskType(MmochatTaskType.击杀鬼怪);
							MmochatMonsterFactory bigMonster = new MmochatMonsterFactory();
							bigMonster.setName("鬼怪");
							bigMonster.setLevel(ghostLevel);
							bigMonster.setBmpType(MmochatRoleBmpType.动物1);
							bigMonster.setDao(3 * MmochatBattleService
									.getStandardDao(ghostLevel, 0) / 2);
							bigMonster.setLevelType(MmochatBossLevelType.自身等级);

							MmochatAttackModeOfNormal attackMode = new MmochatAttackModeOfNormal();
							if (ghostLevel < 30) {
								bigMonster.setEquipLevel(5);
								bigMonster.setTeamNum(3);
								bigMonster.setKillRound(3);
								bigMonster.setPhysical(0.5);
								bigMonster.setMagic(0.35);
								bigMonster.setBossMaxSkillTargetNum(2);
								bigMonster.setSpeedPointAddType(1);
								attackMode
										.setPhysicalAttackOpportunity((int) (64));
								attackMode.setMagicAttackOppotunity((int) (16));
								attackMode.setLimitOppotunity((int) (20));
							} else if (ghostLevel < 60) {
								bigMonster.setEquipLevel(6);
								bigMonster.setTeamNum(1);
								bigMonster.setKillRound(3);
								bigMonster.setPhysical(0.5);
								bigMonster.setMagic(0.35);
								bigMonster.setBossMaxSkillTargetNum(3);
								bigMonster.setSpeedPointAddType(1);
								attackMode
										.setPhysicalAttackOpportunity((int) (64));
								attackMode.setMagicAttackOppotunity((int) (16));
								attackMode.setLimitOppotunity((int) (20));
							} else if (ghostLevel < 90) {
								bigMonster.setEquipLevel(7);
								bigMonster.setTeamNum(1);
								bigMonster.setKillRound(3);
								bigMonster.setPhysical(0.6);
								bigMonster.setMagic(0.42);
								bigMonster.setBossMaxSkillTargetNum(4);
								bigMonster.setSpeedPointAddType(1);
								attackMode
										.setPhysicalAttackOpportunity((int) (56));
								attackMode.setMagicAttackOppotunity((int) (24));
								attackMode.setLimitOppotunity((int) (20));
							} else {
								bigMonster.setEquipLevel(8);
								bigMonster.setTeamNum(1);
								bigMonster.setKillRound(3);
								bigMonster.setPhysical(0.6);
								bigMonster.setMagic(0.42);
								bigMonster.setBossMaxSkillTargetNum(5);
								bigMonster.setSpeedPointAddType(1);
								attackMode
										.setPhysicalAttackOpportunity((int) (56));
								attackMode.setMagicAttackOppotunity((int) (24));
								attackMode.setLimitOppotunity((int) (20));
							}

							bigMonster.setAttackMode_normal(attackMode);

							List<MmochatMonsterFactory> smallMonster = new ArrayList<MmochatMonsterFactory>();
							for (int i1 = 0; i1 < 4; i1++) {
								MmochatMonsterFactory monster = new MmochatMonsterFactory();
								monster.setName("鬼怪");
								monster.setLevel(ghostLevel);
								monster.setBmpType(MmochatRoleBmpType.动物1);
								monster.setDao(3 * MmochatBattleService
										.getStandardDao(ghostLevel, 0) / 2);
								monster.setLevelType(MmochatBossLevelType.自身等级);

								MmochatAttackModeOfNormal attackMode1 = new MmochatAttackModeOfNormal();
								if (ghostLevel < 30) {
									monster.setEquipLevel(5);
									monster.setTeamNum(1);
									monster.setKillRound(3);
									monster.setPhysical(0.5);
									monster.setMagic(0.35);
									monster.setBossMaxSkillTargetNum(2);
									monster.setSpeedPointAddType(1);
									attackMode1
											.setPhysicalAttackOpportunity((int) (64));
									attackMode1
											.setMagicAttackOppotunity((int) (16));
									attackMode1.setLimitOppotunity((int) (20));
								} else if (ghostLevel < 60) {
									monster.setEquipLevel(6);
									monster.setTeamNum(1);
									monster.setKillRound(3);
									monster.setPhysical(0.5);
									monster.setMagic(0.35);
									monster.setBossMaxSkillTargetNum(3);
									monster.setSpeedPointAddType(1);
									attackMode1
											.setPhysicalAttackOpportunity((int) (64));
									attackMode1
											.setMagicAttackOppotunity((int) (16));
									attackMode1.setLimitOppotunity((int) (20));
								} else if (ghostLevel < 90) {
									monster.setEquipLevel(7);
									monster.setTeamNum(1);
									monster.setKillRound(3);
									monster.setPhysical(0.6);
									monster.setMagic(0.42);
									monster.setBossMaxSkillTargetNum(4);
									monster.setSpeedPointAddType(1);
									attackMode1
											.setPhysicalAttackOpportunity((int) (56));
									attackMode1
											.setMagicAttackOppotunity((int) (24));
									attackMode1.setLimitOppotunity((int) (20));
								} else {
									monster.setEquipLevel(8);
									monster.setTeamNum(1);
									monster.setKillRound(3);
									monster.setPhysical(0.6);
									monster.setMagic(0.42);
									monster.setBossMaxSkillTargetNum(5);
									monster.setSpeedPointAddType(1);
									attackMode1
											.setPhysicalAttackOpportunity((int) (56));
									attackMode1
											.setMagicAttackOppotunity((int) (24));
									attackMode1.setLimitOppotunity((int) (20));
								}
								monster.setAttackMode_normal(attackMode1);
								smallMonster.add(monster);
							}
							battle.setBoss(bigMonster);
							battle.setSmallBoss(smallMonster);

						}
					}

					int money = 10000;
					propOwner.addAndUpdateSmall_money(money);
					MmochatStatisticsService.addSmallMoneyEarn(
							MmochatSmallMoneyEarnType.挖藏宝图, money);

					msgMap
							.put(1, "糟了，原来宝图指示的地方禁锢着"
									+ MmochatConstant.ghostNumPerTreasureMap
									+ "只鬼怪!这么一挖，把这群鬼怪放了出来。现在这群鬼怪已经逃到了"
									+ MmochatUtil.wrapColor(map.getMapName()
											+ (propOwner.getLine() + 1) + "线",
											Color.green) + "。你得到了鬼怪落下的" + money
									+ "文钱!");
					String info = "传闻"
							+ MmochatUtil.wrapColor(propOwner.getName(),
									Color.green);
					info += "在挖宝图时意外得放出了"
							+ MmochatConstant.ghostNumPerTreasureMap
							+ "只鬼怪，现在这群鬼怪正在"
							+ MmochatUtil.wrapColor(map.getMapName()
									+ (propOwner.getLine() + 1) + "线",
									Color.yellow) + "作乱，身上还带着不少财宝噢。";
					MmochatChatService.sendSystemMsg(info);
				} else if (percent < 250) {
					// 10W
					propOwner.addAndUpdateSmall_money(100000);
					MmochatStatisticsService.addSmallMoneyEarn(
							MmochatSmallMoneyEarnType.挖藏宝图, 100000);
					msgMap.put(1, "挖到" + MmochatUtil.getColorMoney(100000)
							+ "文钱");
				} else {
					// 5000(3000~7000)
					int money = MmochatUtil.getRandomValue(3000, 7000);
					propOwner.addAndUpdateSmall_money(money);
					MmochatStatisticsService.addSmallMoneyEarn(
							MmochatSmallMoneyEarnType.挖藏宝图, money);
					msgMap.put(1, "挖到" + MmochatUtil.getColorMoney(money)
							+ "文钱");
				}

				// 删除寻宝任务
				propOwner.getTasks().remove(myTask.getTaskId());

				Mmochat_4_12S taskPack = new Mmochat_4_12S();
				taskPack.setTaskId(myTask.getTaskId());
				MmochatUtil.sendCommonPack(propOwner, taskPack);

				// 保存任务到数据库
				try {
					MmochatDao.updateRoleTasks(propOwner);
				} catch (Exception e) {
					e.printStackTrace();
				}
				break;
			}
			case 传送符: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;

					CreateTlvWin tlv = new CreateTlvWin();
					tlv.setWinType(WinType.List);
					tlv.setTitle("全队传送");
					tlv.setRightName("取消");
					tlv.setLeftName("传送");
					tlv.setWinHeight(208);
					tlv.addRightTLV(new CloseWinTLV());
					// mapId,x,y
					tlv.addItemEvent("余杭:衙役", new ClearDataTLV(),
							new AddDataTLV((int) 0),
							new AddDataTLV((short) 598), new AddDataTLV(
									(short) 248));
					tlv.addItemEvent("江宁:道士", new ClearDataTLV(),
							new AddDataTLV((int) 4),
							new AddDataTLV((short) 860), new AddDataTLV(
									(short) 631));
					tlv.addItemEvent("开封:鸿钧道人", new ClearDataTLV(),
							new AddDataTLV((int) 5),
							new AddDataTLV((short) 458), new AddDataTLV(
									(short) 340));
					tlv.addItemEvent("江宁:茅山道士", new ClearDataTLV(),
							new AddDataTLV((int) 4),
							new AddDataTLV((short) 506), new AddDataTLV(
									(short) 848));
					tlv.addItemEvent("余杭:大罗散仙", new ClearDataTLV(),
							new AddDataTLV((int) 0),
							new AddDataTLV((short) 828), new AddDataTLV(
									(short) 227));
					tlv.addItemEvent("余杭:小雅", new ClearDataTLV(),
							new AddDataTLV((int) 0),
							new AddDataTLV((short) 548), new AddDataTLV(
									(short) 629));
					tlv.addLeftTLV(new AddDataTLV((int) gridId));
					tlv.addLeftTLV(new SendDataTLV(MmochatConstant
							.getClientModuleId(),
							MmochatMain.getModuleInstID(),
							MmochatConstant.MSGCODE_MMOCHAT_C_13_9, (int) me
									.getRoleId()));
					ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
					wait.setShowCancel(false);
					tlv.addLeftTLV(wait);
					msgMap.put(2, (TLVStructure) tlv);
					addPropCost = false;
					return msgMap;
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
			}
			case 十级大礼包: {
				if (propUser instanceof MmochatPlayer) {
					addPropCost = false;
					MmochatPlayer me = (MmochatPlayer) propUser;
					if (me.getLevel() < 10) {
						msgMap.put(0, "您还没有达到10级，无法打开大礼包!");
						return msgMap;
					}
					if (!me.hasEnoughPackageSpace(7)) {
						msgMap.put(0, "请先清理出7个包裹空位，以免礼物掉落!");
						return msgMap;
					}

					// 赠送新手装备
					int equipLevel = 10;
					int modifyLevel = 1;
					MmochatEquip equip = MmochatEquipService.createRandomEquip(
							true, MmochatEquipType.头盔, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.武器, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.衣服, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.鞋子, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					// 小法池,小血玲珑,神行法宝残片
					MmochatProp newProp = new MmochatProp(MmochatPropType.小法池);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					newProp = new MmochatProp(MmochatPropType.小血玲珑);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					newProp = new MmochatProp(MmochatPropType.神行法宝残片);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					// 20级礼包
					newProp = new MmochatProp(MmochatPropType.二十级大礼包);
					newProp.setCanDrop(false);
					newProp.setCanDeal(false);
					grid.setObject(newProp);
					msgMap.put(1, "您打开10级大礼包获得了一套10级改" + modifyLevel
							+ "装备、小法池、小血玲珑、神行法宝残片!");
					break;
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
			}
			case 二十级大礼包: {
				if (propUser instanceof MmochatPlayer) {
					addPropCost = false;
					MmochatPlayer me = (MmochatPlayer) propUser;
					if (me.getLevel() < 20) {
						msgMap.put(0, "您还没有达到20级，无法打开大礼包!");
						return msgMap;
					}
					if (!me.hasEnoughPackageSpace(8)) {
						msgMap.put(0, "请先清理出8个包裹空位，以免礼物掉落!");
						return msgMap;
					}

					// 赠送新手装备
					int equipLevel = 20;
					int modifyLevel = 1;
					MmochatEquip equip = MmochatEquipService.createRandomEquip(
							true, MmochatEquipType.头盔, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.武器, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.衣服, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.鞋子, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					// 龙涎香,还原丹X20,八卦令,喇叭X2
					MmochatProp newProp = new MmochatProp(MmochatPropType.龙涎香);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					newProp = new MmochatProp(MmochatPropType.还原丹);
					newProp.setCanDeal(false);
					newProp.setOverlapNum(20);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					newProp = new MmochatProp(MmochatPropType.八卦令);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					newProp = new MmochatProp(MmochatPropType.喇叭);
					newProp.setCanDeal(false);
					newProp.setOverlapNum(2);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					// 30级礼包
					newProp = new MmochatProp(MmochatPropType.三十级大礼包);
					newProp.setCanDrop(false);
					newProp.setCanDeal(false);
					grid.setObject(newProp);
					msgMap.put(1, "您打开20级大礼包获得了一套20级改" + modifyLevel
							+ "装备、龙涎香、还原丹、八卦令、喇叭!");
					break;
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
			}
			case 三十级大礼包: {
				if (propUser instanceof MmochatPlayer) {
					addPropCost = false;
					MmochatPlayer me = (MmochatPlayer) propUser;
					if (me.getLevel() < 30) {
						msgMap.put(0, "您还没有达到30级，无法打开大礼包!");
						return msgMap;
					}
					if (!me.hasEnoughPackageSpace(6)) {
						msgMap.put(0, "请先清理出6个包裹空位，以免礼物掉落!");
						return msgMap;
					}

					// 赠送新手装备
					int equipLevel = 30;
					int modifyLevel = 1;
					MmochatEquip equip = MmochatEquipService.createRandomEquip(
							true, MmochatEquipType.头盔, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.武器, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.衣服, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.鞋子, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					// 传送符,天尊令
					MmochatProp newProp = new MmochatProp(MmochatPropType.传送符);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					newProp = new MmochatProp(MmochatPropType.天尊令);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					// 40级礼包
					newProp = new MmochatProp(MmochatPropType.四十级大礼包);
					newProp.setCanDrop(false);
					newProp.setCanDeal(false);
					grid.setObject(newProp);
					msgMap.put(1, "您打开30级大礼包获得了一套30级改" + modifyLevel
							+ "装备、传送符、天尊令!");
					break;
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
			}
			case 四十级大礼包: {
				if (propUser instanceof MmochatPlayer) {
					addPropCost = false;
					MmochatPlayer me = (MmochatPlayer) propUser;
					if (me.getLevel() < 40) {
						msgMap.put(0, "您还没有达到40级，无法打开大礼包!");
						return msgMap;
					}
					if (!me.hasEnoughPackageSpace(7)) {
						msgMap.put(0, "请先清理出7个包裹空位，以免礼物掉落!");
						return msgMap;
					}

					// 赠送新手装备
					int equipLevel = 40;
					int modifyLevel = 2;
					MmochatEquip equip = MmochatEquipService.createRandomEquip(
							true, MmochatEquipType.头盔, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.武器, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.衣服, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.鞋子, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					// 银联卡,道尊令，2个超级改造石
					MmochatProp newProp = new MmochatProp(MmochatPropType.银联卡);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					newProp = new MmochatProp(MmochatPropType.道尊令);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					newProp = new MmochatProp(MmochatPropType.超级改造石);
					newProp.setCanDeal(false);
					newProp.setOverlapNum(2);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					// 50级礼包
					newProp = new MmochatProp(MmochatPropType.五十级大礼包);
					newProp.setCanDrop(false);
					newProp.setCanDeal(false);
					grid.setObject(newProp);
					msgMap.put(1, "您打开40级大礼包获得了一套40级改" + modifyLevel
							+ "装备、银联卡、道尊令、2块超级改造石!");
					break;
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
			}
			case 五十级大礼包: {
				if (propUser instanceof MmochatPlayer) {
					addPropCost = false;
					MmochatPlayer me = (MmochatPlayer) propUser;
					if (me.getLevel() < 50) {
						msgMap.put(0, "您还没有达到50级，无法打开大礼包!");
						return msgMap;
					}
					if (!me.hasEnoughPackageSpace(6)) {
						msgMap.put(0, "请先清理出6个包裹空位，以免礼物掉落!");
						return msgMap;
					}

					// 赠送新手装备
					int equipLevel = 50;
					int modifyLevel = 2;
					MmochatEquip equip = MmochatEquipService.createRandomEquip(
							true, MmochatEquipType.头盔, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.武器, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.衣服, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.鞋子, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					// 驭兽令,急急如律令
					MmochatProp newProp = new MmochatProp(MmochatPropType.驭兽令);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					newProp = new MmochatProp(MmochatPropType.急急如律令);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					// 60级礼包
					newProp = new MmochatProp(MmochatPropType.六十级大礼包);
					newProp.setCanDrop(false);
					newProp.setCanDeal(false);
					grid.setObject(newProp);
					msgMap.put(1, "您打开50级大礼包获得了一套50级改" + modifyLevel
							+ "装备、驭兽令、急急如律令!");
					break;
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
			}
			case 六十级大礼包: {
				if (propUser instanceof MmochatPlayer) {
					addPropCost = false;
					MmochatPlayer me = (MmochatPlayer) propUser;
					if (me.getLevel() < 60) {
						msgMap.put(0, "您还没有达到60级，无法打开大礼包!");
						return msgMap;
					}
					if (!me.hasEnoughPackageSpace(6)) {
						msgMap.put(0, "请先清理出6个包裹空位，以免礼物掉落!");
						return msgMap;
					}

					// 赠送新手装备
					int equipLevel = 60;
					int modifyLevel = 2;
					MmochatEquip equip = MmochatEquipService.createRandomEquip(
							true, MmochatEquipType.头盔, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.武器, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.衣服, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.鞋子, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					// 驱兽令,赎罪牌
					MmochatProp newProp = new MmochatProp(MmochatPropType.驱兽令);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					newProp = new MmochatProp(MmochatPropType.赎罪牌);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					// 70级礼包
					newProp = new MmochatProp(MmochatPropType.七十级大礼包);
					newProp.setCanDrop(false);
					newProp.setCanDeal(false);
					grid.setObject(newProp);
					msgMap.put(1, "您打开60级大礼包获得了一套60级改" + modifyLevel
							+ "装备、驱兽令、赎罪牌!");
					break;
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
			}
			case 七十级大礼包: {
				if (propUser instanceof MmochatPlayer) {
					addPropCost = false;
					MmochatPlayer me = (MmochatPlayer) propUser;
					if (me.getLevel() < 70) {
						msgMap.put(0, "您还没有达到70级，无法打开大礼包!");
						return msgMap;
					}
					if (!me.hasEnoughPackageSpace(3)) {
						msgMap.put(0, "请先清理出3个包裹空位，以免礼物掉落!");
						return msgMap;
					}

					// 迟滞水,超级轮回丹,神行法宝体力丹
					MmochatProp newProp = new MmochatProp(MmochatPropType.迟滞水);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					newProp = new MmochatProp(MmochatPropType.超级成长丹);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					newProp = new MmochatProp(MmochatPropType.神行法宝体力丹);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					// 80级礼包
					newProp = new MmochatProp(MmochatPropType.八十级大礼包);
					newProp.setCanDrop(false);
					newProp.setCanDeal(false);
					grid.setObject(newProp);
					msgMap.put(1, "您打开70级大礼包获得了迟滞水、超级成长丹、神行法宝体力丹!");
					break;
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
			}
			case 八十级大礼包: {
				if (propUser instanceof MmochatPlayer) {
					addPropCost = false;
					MmochatPlayer me = (MmochatPlayer) propUser;
					if (me.getLevel() < 80) {
						msgMap.put(0, "您还没有达到80级，无法打开大礼包!");
						return msgMap;
					}
					if (!me.hasEnoughPackageSpace(2)) {
						msgMap.put(0, "请先清理出2个包裹空位，以免礼物掉落!");
						return msgMap;
					}

					// VIP周卡、神行法宝聚灵丹
					MmochatProp newProp = new MmochatProp(MmochatPropType.会员周卡);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					newProp = new MmochatProp(MmochatPropType.神行法宝聚灵丹);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					grid.setObject(null);
					msgMap.put(1, "您打开80级大礼包获得了会员周卡、神行法宝聚灵丹!"
							+ "新手大礼包已经全部打开，礼包消失。请按9键进入商城，了解更多道具功能。");
					break;
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
			}
			case 神行法宝灵气丹: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;
					// 检查是否有使用中的神行法宝
					MmochatPackageGrid grid1 = me.getMyPackage().get(
							MmochatSuperMachineType.神行法宝.getGridId());
					if (grid1 == null || grid1.getObject() == null) {
						msgMap.put(0, "请先将您需要补充灵气的神行法宝设置为使用中"
								+ "(打开包裹，点击法宝，选择菜单中的<使用>)!");
						return msgMap;
					}
					MmochatCommonObject superMachine = grid1.getObject();
					// 检查神行法宝是否已经满级
					int curSpeedLevel = superMachine.getFlyMachineSpeedLevel();
					int curFlyLevel = superMachine.getFlyMachineFlyLevel();
					if (curSpeedLevel == MmochatCommonObject.flyMachineMaxSpeedLevel
							&& curFlyLevel == MmochatCommonObject.flyMachineMaxFlyLevel) {
						msgMap.put(0, "您当前使用中的神行法宝已满级，无法再升级!");
						return msgMap;
					}

					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					superMachine.addFlyMachineExp(100);
					msgMap.put(1, "您当前使用中的神行法宝增加了100点灵气!");
					gridNeedUpdatePack.addGrid(grid1);
					break;
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
			}
			case 神行法宝聚灵丹: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;
					// 检查是否有使用中的神行法宝
					MmochatPackageGrid grid1 = me.getMyPackage().get(
							MmochatSuperMachineType.神行法宝.getGridId());
					if (grid1 == null || grid1.getObject() == null) {
						msgMap.put(0, "请先将您需要补充灵气的神行法宝设置为使用中"
								+ "(打开包裹，点击法宝，选择菜单中的<使用>)!");
						return msgMap;
					}
					MmochatCommonObject superMachine = grid1.getObject();
					// 检查神行法宝是否已经满级
					int curSpeedLevel = superMachine.getFlyMachineSpeedLevel();
					int curFlyLevel = superMachine.getFlyMachineFlyLevel();
					if (curSpeedLevel == MmochatCommonObject.flyMachineMaxSpeedLevel
							&& curFlyLevel == MmochatCommonObject.flyMachineMaxFlyLevel) {
						msgMap.put(0, "您当前使用中的神行法宝已满级，无法再升级!");
						return msgMap;
					}

					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					// 400到1000之间随机,期望570(1.2倍)
					int addValue;
					int p1 = MmochatUtil.getRandomValue(30);
					if (p1 < 7) {
						// 600-1000
						addValue = MmochatUtil.getRandomValue(600, 1000);
					} else {
						// 400-600
						addValue = MmochatUtil.getRandomValue(400, 600);
					}

					superMachine.addFlyMachineExp(addValue);
					msgMap.put(1, "您当前使用中的神行法宝增加了" + addValue + "点灵气!");
					gridNeedUpdatePack.addGrid(grid1);
					break;
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
			}
			case 神行法宝体力丹: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;
					// 检查是否有使用中的神行法宝
					MmochatPackageGrid grid1 = me.getMyPackage().get(
							MmochatSuperMachineType.神行法宝.getGridId());
					if (grid1 == null || grid1.getObject() == null) {
						msgMap.put(0, "请先将您需要补充体力的神行法宝设置为使用中"
								+ "(打开包裹，点击法宝，选择菜单中的<使用>)!");
						return msgMap;
					}
					MmochatCommonObject superMachine = grid1.getObject();

					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}

					if (superMachine.getFlyMachineCanUseTotalValue() <= 0) {
						// 体力之前已经用光
						superMachine.setFlyMachineUseStartTime((new Date())
								.getTime());
						superMachine.setFlyMachineCanUseTotalValue(1000);
						superMachine.setFlyMachineCanUseValue(1000);
					} else {
						superMachine.addFlyMachineCanUseTotalValue(1000);
						superMachine.addFlyMachineCanUseValue(1000);
					}
					msgMap.put(1, "您当前使用中的神行法宝增加了1000点体力!");
					gridNeedUpdatePack.addGrid(grid1);
					break;
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
			}
			case 照妖镜: {
				// 检查已有任务
				MmochatTask myTask = propOwner
						.getTaskByType(MmochatTaskType.真假情报);
				if (MmochatTeamService.getTeamState(propOwner) == MmochatTeamStateType.队员) {
					msgMap.put(0, "你不是队长，无法使用照妖镜!");
					return msgMap;
				}
				if (myTask == null
						|| myTask.getTaskState() != MmochatTaskStateType.已接) {
					msgMap.put(0, "你身上没有真假情报任务。70级以后可以去江宁找茅山道士领取任务。");
					return msgMap;
				}
				int turn = myTask.getTaskTurn();
				int mapId = myTask.getTargetMapId();
				int treasureX = myTask.getTargetX();
				int treasureY = myTask.getTargetY();
				int curMapId = propOwner.getMapId();
				int x = propOwner.getX();
				int y = propOwner.getY();
				if (curMapId != mapId) {
					msgMap.put(0, "还没到妖气所在的地图呢!");
					return msgMap;
				}
				if (Math.abs(treasureX - x) > 60
						|| Math.abs(treasureY - y) > 60) {
					msgMap.put(0, "还没到妖气所在的位置呢!");
					return msgMap;
				}
				addPropCost = false;
				// 扣除道具
				if (prop.isCanOverlap()) {
					prop.delOverlapNum(1);
					if (prop.getOverlapNum() <= 0) {
						grid.setObject(null);
						MmochatStatisticsService.addPropCost(propType, 1);
					}
				} else {
					prop.delAmount(1);
					if (prop.getCurPropAmount() <= 0) {
						grid.setObject(null);
						MmochatStatisticsService.addPropCost(propType, 1);
					}
				}

				List<MmochatPlayer> teamers = MmochatTeamService
						.getMyTeamMember(propOwner);
				if (MmochatUtil.isInPercent(10)) {
					// 假情报
					msgMap.put(1, "好像什么也没有照出来!看来这个情报是假的，任务完成。");
					for (MmochatPlayer me : teamers) {
						MmochatTask theTask = me
								.getTaskById(myTask.getTaskId());
						if (theTask != null
								&& theTask.getTaskState() == MmochatTaskStateType.已接) {
							theTask.setTaskState(MmochatTaskStateType.已完成);
							theTask.addTaskTurn();
							me.addZhanji(20);
							// 下发删除任务
							Mmochat_4_12S taskPack = new Mmochat_4_12S();
							taskPack.setTaskId(theTask.getTaskId());
							MmochatUtil.sendCommonPack(me, taskPack);

							MmochatChatService.sendSystemMsgToPerson(me,
									"这里什么都没有，看来是个假情报，任务完成。您获得了20点战绩。");
						}
					}
				} else {
					// 遇怪战斗
					int equipLevel;
					int expectTeamNum = 3;
					double bossPhysicalAttack = 0, bossPhysicalAttackPercent = 0, bossMagicAttack = 0, bossMagicAttackPercent = 0;
					double monsterPhysicalAttack = 0, monsterPhysicalAttackPercent = 0, monsterMagicAttack = 0, monsterMagicAttackPercent = 0;
					int bossSuperPhysicalAttack = 0, bossSuperSpritAttack = 0;
					int monsterSuperPhysicalAttack = 0, monsterSuperSpritAttack = 0;
					int bossMagicAttackNum = 3;
					int maxLevel = propOwner.getTrueLevel();
					for (MmochatPlayer me : teamers) {
						maxLevel = Math.max(maxLevel, me.getTrueLevel());
					}
					bossPhysicalAttack = 0.4;
					bossMagicAttack = 0.3;
					bossPhysicalAttackPercent = 0.75;
					bossMagicAttackPercent = 0.25;
					bossMagicAttackNum = 5;
					bossSuperPhysicalAttack = 10;
					bossSuperSpritAttack = 10;
					monsterPhysicalAttack = 0.2;
					monsterMagicAttack = 0.15;
					monsterPhysicalAttackPercent = 1;
					monsterMagicAttackPercent = 0;
					monsterSuperPhysicalAttack = 5;
					monsterSuperSpritAttack = 5;
					equipLevel = 6;

					MmochatNpcBattle battle = new MmochatNpcBattle();
					MmochatMonsterFactory boss = new MmochatMonsterFactory();
					boss.setLevelType(MmochatBossLevelType.队伍最高等级);
					boss.setBmpType(MmochatRoleBmpType
							.getRandomMonsterBmpType());
					boss.setName("妖王");
					boss.setLevel(maxLevel);
					boss.setEquipLevel(equipLevel);
					boss.setTeamNum(expectTeamNum);
					boss.setKillRound(2);
					boss.setPhysical(bossPhysicalAttack);
					boss.setMagic(bossMagicAttack);
					boss.setSuperPhysicalAttack(bossSuperPhysicalAttack);
					boss.setSuperSpritAttack(bossSuperSpritAttack);
					boss.setBossMaxSkillTargetNum(bossMagicAttackNum);
					boss.setSpeedPointAddType(3);
					MmochatAttackModeOfNormal defaultAttackMode = new MmochatAttackModeOfNormal();
					defaultAttackMode
							.setPhysicalAttackOpportunity((int) (100 * bossPhysicalAttackPercent));
					defaultAttackMode
							.setMagicAttackOppotunity((int) (100 * bossMagicAttackPercent));
					defaultAttackMode
							.setLimitOppotunity((int) (100 * (1 - bossMagicAttackPercent - bossPhysicalAttackPercent)));
					boss.setAttackMode_normal(defaultAttackMode);

					boss
							.setDao((int) (boss.getDaoParam() * MmochatBattleService
									.getStandardDao(maxLevel, 0)));
					boss.setAntiConfuse(turn);
					boss.setAntiFreeze(turn);
					boss.setAntiSeal(turn);
					battle.setBoss(boss);

					// 道具:如果使用了满卡，则小怪数+大怪数量固定为2XteamNum,
					int teamNum = teamers.size();
					int monsterNum = 0;
					if (propOwner.hasPropEffect(MmochatPropType.顶级急急如律令
							.getEffectKey())) {
						monsterNum = teamNum * 5;
					} else if (propOwner.hasPropEffect(MmochatPropType.特级急急如律令
							.getEffectKey())) {
						monsterNum = (int) (teamNum * 3.4);
					} else if (propOwner.hasPropEffect(MmochatPropType.超级急急如律令
							.getEffectKey())) {
						monsterNum = (int) (teamNum * 2.5);
					} else if (propOwner.hasPropEffect(MmochatPropType.急急如律令
							.getEffectKey())) {
						monsterNum = teamNum * 2;
					} else {
						monsterNum = teamNum
								+ (int) (Math.random() * (teamNum + 1));
					}
					monsterNum = Math.min(10, monsterNum);
					monsterNum = monsterNum - 1;

					MmochatRoleBmpType monsterBmpType = MmochatRoleBmpType
							.getRandomMonsterBmpType();
					List<MmochatMonsterFactory> monsters = new ArrayList<MmochatMonsterFactory>();
					for (int i = 0; i < monsterNum; i++) {
						MmochatMonsterFactory monster = new MmochatMonsterFactory();
						monster.setLevelType(MmochatBossLevelType.队伍最高等级);
						monster.setBmpType(monsterBmpType);
						monster.setName("小妖");
						monster.setLevel(maxLevel);
						monster.setEquipLevel(equipLevel);
						monster.setTeamNum(expectTeamNum);
						monster.setKillRound(1);
						monster.setPhysical(monsterPhysicalAttack);
						monster.setMagic(monsterMagicAttack);
						monster.setBossMaxSkillTargetNum(2);
						monster
								.setSuperPhysicalAttack(monsterSuperPhysicalAttack);
						monster.setSuperSpritAttack(monsterSuperSpritAttack);
						monster.setSpeedPointAddType(0);
						MmochatAttackModeOfNormal attackMode = new MmochatAttackModeOfNormal();
						attackMode
								.setPhysicalAttackOpportunity((int) (100 * monsterPhysicalAttackPercent));
						attackMode
								.setMagicAttackOppotunity((int) (100 * monsterMagicAttackPercent));
						attackMode.setLimitOppotunity(0);
						monster.setAttackMode_normal(attackMode);
						monster
								.setDao((int) (monster.getDaoParam() * MmochatBattleService
										.getStandardDao(maxLevel, 0)));
						monsters.add(monster);
					}
					battle.setSmallBoss(monsters);

					MmochatTask task = new MmochatTask();
					task.setTaskId(myTask.getTaskId());
					task.setTaskType(MmochatTaskType.真假情报);
					task.setFinish_need_battles(battle);

					for (MmochatPlayer me : teamers) {
						MmochatTask theTask = me
								.getTaskById(myTask.getTaskId());
						if (theTask != null
								&& theTask.getTaskState() == MmochatTaskStateType.已接) {
							theTask.setTaskLevel(maxLevel);
						}
					}

					MmochatBattleService.enterNpcPk(propOwner.getMapId(),
							(byte) propOwner.getLine(), teamers, propOwner
									.getRoleId(), task, null);
					msgMap.put(3, true);
					break;
				}
				break;
			}
			case 改造小礼包:
			case 改造大礼包:
			case 改造灵珠小礼包:
			case 改造灵珠大礼包:
			case 升级小礼包:
			case 升级大礼包:
			case 刷道小礼包:
			case 刷道大礼包:
			case 至尊大礼包: {
				if (propUser instanceof MmochatPlayer) {
					Object propInfo[][];
					int awardBigMoney;

					switch (prop.getPropType()) {
					case 改造小礼包: {
						Object propInfos[][] = { { MmochatPropType.超级改造石, 20 },
								{ MmochatPropType.混沌石, 10 },
								{ MmochatPropType.金钱袋, 5 },
								{ MmochatPropType.节日锦囊, 2 } };
						propInfo = propInfos;
						awardBigMoney = 4988;
						break;
					}
					case 改造大礼包: {
						// 40个超级改造石,20个混沌石,10个金钱袋,5个节日锦囊,1个银联卡,20个喇叭
						Object propInfos[][] = { { MmochatPropType.超级改造石, 40 },
								{ MmochatPropType.混沌石, 20 },
								{ MmochatPropType.金钱袋, 10 },
								{ MmochatPropType.节日锦囊, 5 },
								{ MmochatPropType.银联卡, 1 },
								{ MmochatPropType.喇叭, 20 } };
						propInfo = propInfos;
						awardBigMoney = 9888;
						break;
					}
					case 改造灵珠小礼包: {
						// 10个改造灵珠,5个混沌石,5个金钱袋,2个节日锦囊!有机率额外获得7500元宝
						Object propInfos[][] = { { MmochatPropType.改造灵珠, 10 },
								{ MmochatPropType.混沌石, 5 },
								{ MmochatPropType.金钱袋, 5 },
								{ MmochatPropType.节日锦囊, 2 } };
						propInfo = propInfos;
						awardBigMoney = 7500;
						break;
					}
					case 改造灵珠大礼包: {
						// 20个改造灵珠,10个混沌石,10个金钱袋,7个节日锦囊,
						// 1个银联卡,20个喇叭!有机率额外获得15000元宝
						Object propInfos[][] = { { MmochatPropType.改造灵珠, 20 },
								{ MmochatPropType.混沌石, 10 },
								{ MmochatPropType.金钱袋, 10 },
								{ MmochatPropType.节日锦囊, 7 },
								{ MmochatPropType.银联卡, 1 },
								{ MmochatPropType.喇叭, 20 } };
						propInfo = propInfos;
						awardBigMoney = 15000;
						break;
					}
					case 升级小礼包: {
						// 2个天尊令,2个驱兽令,2个急急如律令,1个小血石,1个中法池,
						// 20个喇叭,1个赎罪牌,2个节日锦囊!有机率获得928元宝
						Object propInfos[][] = { { MmochatPropType.天尊令, 2 },
								{ MmochatPropType.驱兽令, 2 },
								{ MmochatPropType.急急如律令, 2 },
								{ MmochatPropType.小血石, 1 },
								{ MmochatPropType.中法池, 1 },
								{ MmochatPropType.喇叭, 20 },
								{ MmochatPropType.赎罪牌, 1 },
								{ MmochatPropType.节日锦囊, 2 } };
						propInfo = propInfos;
						awardBigMoney = 928;
						break;
					}
					case 升级大礼包: {
						// 10个天尊令,10个驱兽令,10个急急如律令,2个照妖镜,2个大血石,2个大法池,
						// 20个喇叭,3个赎罪牌,5个节日锦囊,3个强化丹o高力,3个强化丹o通灵!
						// 有机率额外获得4888元宝
						Object propInfos[][] = { { MmochatPropType.天尊令, 10 },
								{ MmochatPropType.驱兽令, 10 },
								{ MmochatPropType.急急如律令, 10 },
								{ MmochatPropType.照妖镜, 2 },
								{ MmochatPropType.大血石, 2 },
								{ MmochatPropType.大法池, 2 },
								{ MmochatPropType.喇叭, 20 },
								{ MmochatPropType.赎罪牌, 3 },
								{ MmochatPropType.节日锦囊, 5 },
								{ MmochatPropType.强化丹o高力, 3 },
								{ MmochatPropType.强化丹o通灵, 3 } };
						propInfo = propInfos;
						awardBigMoney = 4888;
						break;
					}
					case 刷道小礼包: {
						// 2个天尊令,2个驱兽令,2个急急如律令,2个传送符,12个喇叭
						// 1个龙涎香,1个赎罪牌,2个节日锦囊!有机率得1188元宝
						Object propInfos[][] = { { MmochatPropType.天尊令, 2 },
								{ MmochatPropType.驱兽令, 2 },
								{ MmochatPropType.急急如律令, 2 },
								{ MmochatPropType.传送符, 2 },
								{ MmochatPropType.喇叭, 12 },
								{ MmochatPropType.龙涎香, 1 },
								{ MmochatPropType.赎罪牌, 1 },
								{ MmochatPropType.节日锦囊, 2 } };
						propInfo = propInfos;
						awardBigMoney = 1188;
						break;
					}
					case 刷道大礼包: {
						// 10个天尊令,10个驱兽令,10个急急如律令,10个传送符,10个鬼灵珠,
						// 20个喇叭,1个龙涎香,3个赎罪牌,5个节日锦囊,3个强化丹o幻影!有机率得5288元宝
						Object propInfos[][] = { { MmochatPropType.天尊令, 10 },
								{ MmochatPropType.驱兽令, 10 },
								{ MmochatPropType.急急如律令, 10 },
								{ MmochatPropType.传送符, 10 },
								{ MmochatPropType.鬼灵珠, 10 },
								{ MmochatPropType.喇叭, 20 },
								{ MmochatPropType.龙涎香, 1 },
								{ MmochatPropType.赎罪牌, 3 },
								{ MmochatPropType.节日锦囊, 5 },
								{ MmochatPropType.强化丹o幻影, 3 } };
						propInfo = propInfos;
						awardBigMoney = 5288;
						break;
					}
					case 至尊大礼包:
					default: {
						// 1个会员月卡,1个江湖名号,1个超级轮回水,1个超级后悔药
						// 1个超级洗髓丹,1个脱胎换骨水,5个神行法宝体力丹,3个赎罪牌,20个喇叭,
						// 10个节日锦囊!一定机率额外获得8888元宝!
						Object propInfos[][] = { { MmochatPropType.会员月卡, 1 },
								{ MmochatPropType.江湖名号, 1 },
								{ MmochatPropType.超级轮回水, 1 },
								{ MmochatPropType.超级后悔药, 1 },
								{ MmochatPropType.超级洗髓丹, 1 },
								{ MmochatPropType.脱胎换骨水, 1 },
								{ MmochatPropType.神行法宝体力丹, 5 },
								{ MmochatPropType.赎罪牌, 3 },
								{ MmochatPropType.喇叭, 20 },
								{ MmochatPropType.节日锦囊, 10 } };
						propInfo = propInfos;
						awardBigMoney = 8888;
						break;
					}
					}

					int gridNeed = 0;
					for (int i = 0; i < propInfo.length; i++) {
						MmochatPropType curPropType = (MmochatPropType) propInfo[i][0];
						int curPropCount = (Integer) propInfo[i][1];
						if (curPropType.isCanOverLap()) {
							gridNeed += (curPropCount + 19) / 20;
						} else {
							gridNeed += curPropCount;
						}
					}

					if (!propOwner.hasEnoughPackageSpace(gridNeed)) {
						msgMap.put(0, "您的包裹太满,请先清理出" + gridNeed + "个空位!");
						return msgMap;
					}
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}

					MmochatPlayer me = (MmochatPlayer) propUser;
					String awardMsg = "";
					// 元宝奖励 1%
					if (MmochatUtil.isInPercent(1)) {
						me.addBig_money(awardBigMoney);
						MmochatStatisticsService.addBigMoneyEarn(
								MmochatBigMoneyEarnType.限时礼包, awardBigMoney);
						awardMsg += MmochatUtil.wrapColor(
								awardBigMoney + "元宝、", Color.red);
						systemMsg = MmochatUtil.wrapColor(me.getName(),
								Color.yellow)
								+ "打开<"
								+ prop.getPropType().toString()
								+ ">时，意外获得免单机会，得到"
								+ MmochatUtil.wrapColor(awardBigMoney + "元宝",
										Color.yellow) + "的返还!";
					}

					for (int i = 0; i < propInfo.length; i++) {
						MmochatPropType curPropType = (MmochatPropType) propInfo[i][0];
						int curPropCount = (Integer) propInfo[i][1];
						if (curPropType.isCanOverLap()) {
							MmochatProp newProp = new MmochatProp(curPropType);
							newProp.setOverlapNum(curPropCount);
							me.addObjectToPackage(newProp);
						} else {
							for (int j = 0; j < curPropCount; j++) {
								MmochatProp newProp = new MmochatProp(
										curPropType);
								me.addObjectToPackage(newProp);
							}
						}
						awardMsg += curPropCount + "个" + curPropType.toString()
								+ "、";
					}
					msgMap.put(1, "您打开" + prop.getPropType().toString() + "获得了"
							+ MmochatUtil.wrapColor(awardMsg, Color.yellow));
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;
			}
			case 龙年大礼包:
			case 元宵节礼包: {
				if (propUser instanceof MmochatPlayer) {
					addPropCost = false;
					if (!propOwner.hasEnoughPackageSpace(2)) {
						msgMap.put(0, "您的包裹太满,请先清理出两个空位!");
						return msgMap;
					}
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					MmochatPlayer me = (MmochatPlayer) propUser;
					String awardMsg = "";
					// 元宝1000 0.1%
					if (MmochatUtil.isInPercent(0.1)) {
						me.addBig_money(1000);
						MmochatStatisticsService.addBigMoneyEarn(
								MmochatBigMoneyEarnType.龙年大礼包和元宵节礼包, 1000);
						awardMsg += MmochatUtil.wrapColor("1000元宝",
								Color.yellow);
						systemMsg = MmochatUtil.wrapColor(me.getName(),
								Color.yellow)
								+ "打开<"
								+ prop.getPropType().toString()
								+ ">喜得"
								+ MmochatUtil.wrapColor("1000元宝", Color.yellow)
								+ "!";
					}

					// 金钱10000 100%
					int money = 10000;
					me.addAndUpdateSmall_money(money);
					MmochatStatisticsService.addSmallMoneyEarn(
							MmochatSmallMoneyEarnType.龙年大礼包和元宵节礼包, money);
					awardMsg += MmochatUtil.getColorMoney(money) + "文钱、";

					// 道行2年 100%
					int dao = MmochatUtil.getRandomValue(730, 1460);
					// 刷道比赛
					MmochatPropService.dealDaoActivity(me, dao);

					int trueDao = MmochatBattleService.getRealDao(me, dao);
					me.addDao(trueDao);
					awardMsg += trueDao + "天道行、";

					// 第一格道具
					double rate = Math.random() * 100;

					// propType->机率
					Object propRate[][] = { { MmochatPropType.八卦令, 1.0 },
							{ MmochatPropType.赎罪牌, 1.0 },
							{ MmochatPropType.照妖镜, 1.0 },
							{ MmochatPropType.白水晶, 20.0 },
							{ MmochatPropType.改造石, 20.0 },
							{ MmochatPropType.混沌石, 0.5 },
							{ MmochatPropType.超级白水晶, 0.1 },
							{ MmochatPropType.超级改造石, 0.1 },
							{ MmochatPropType.粉水晶, 0.1 },
							{ MmochatPropType.金水晶, 0.1 },
							{ MmochatPropType.绿水晶, 0.1 },
							{ MmochatPropType.升级石, 0.5 },
							{ MmochatPropType.神行法宝灵气丹, 1.0 },
							{ MmochatPropType.神行法宝聚灵丹, 1.0 },
							{ MmochatPropType.神行法宝体力丹, 1.0 },
							{ MmochatPropType.年兽蛋, 10.0 } };

					MmochatPropType p1Type = null;
					double curRate = 0;
					for (int i = 0; i < propRate.length; i++) {
						curRate += (Double) propRate[i][1];
						if (curRate > rate) {
							// 命中道具
							p1Type = (MmochatPropType) propRate[i][0];
							break;
						}
					}
					if (p1Type != null) {
						MmochatProp newProp = new MmochatProp(p1Type);
						newProp.setCanDeal(prop.isCanDeal());
						me.addObjectToPackage(newProp);
						awardMsg += newProp.getType().toString() + "、";
					}

					// 第二格道具
					rate = Math.random() * 100;
					p1Type = null;
					Object propRate2[][] = { { MmochatPropType.急急如律令, 15.0 },
							{ MmochatPropType.天尊令, 15.0 },
							{ MmochatPropType.道尊令, 15.0 },
							{ MmochatPropType.驱兽令, 15.0 },
							{ MmochatPropType.驭兽令, 15.0 },
							{ MmochatPropType.小血石, 1.0 },
							{ MmochatPropType.小血瓶, 1.0 },
							{ MmochatPropType.小法池, 1.0 },
							{ MmochatPropType.小法玲珑, 1.0 },
							{ MmochatPropType.中血石, 1.0 },
							{ MmochatPropType.中血瓶, 1.0 },
							{ MmochatPropType.中法池, 1.0 },
							{ MmochatPropType.中法玲珑, 1.0 } };
					curRate = 0;
					for (int i = 0; i < propRate2.length; i++) {
						curRate += (Double) propRate2[i][1];
						if (curRate > rate) {
							// 命中道具
							p1Type = (MmochatPropType) propRate2[i][0];
							break;
						}
					}

					if (p1Type != null) {
						MmochatProp newProp = new MmochatProp(p1Type);
						newProp.setCanDeal(prop.isCanDeal());
						me.addObjectToPackage(newProp);
						awardMsg += newProp.getType().toString() + "、";
					}

					msgMap.put(1, "您打开" + prop.getPropType().toString() + "获得了"
							+ awardMsg + "恭喜恭喜!");
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;
			}
			case 新年大礼包: {
				if (propUser instanceof MmochatPlayer) {
					addPropCost = false;
					if (!propOwner.hasEnoughPackageSpace(2)) {
						msgMap.put(0, "您的包裹太满,请先清理出两个空位!");
						return msgMap;
					}
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					MmochatPlayer me = (MmochatPlayer) propUser;
					String awardMsg = "";
					// 元宝1000 0.2%
					if (MmochatUtil.isInPercent(0.2)) {
						me.addBig_money(1000);
						MmochatStatisticsService.addBigMoneyEarn(
								MmochatBigMoneyEarnType.新年大礼包, 1000);
						awardMsg += MmochatUtil.wrapColor("1000元宝",
								Color.yellow);
						systemMsg = MmochatUtil.wrapColor(me.getName(),
								Color.yellow)
								+ "打开<新年大礼包>喜得"
								+ MmochatUtil.wrapColor("1000元宝", Color.yellow)
								+ "!";
					}

					// 金钱10000 100%
					int money = MmochatUtil.getRandomValue(5000, 15000);
					me.addAndUpdateSmall_money(money);
					MmochatStatisticsService.addSmallMoneyEarn(
							MmochatSmallMoneyEarnType.新年大礼包, money);
					awardMsg += MmochatUtil.getColorMoney(money) + "文钱、";

					// 道行2年 100%
					int dao = MmochatUtil.getRandomValue(730, 1460);
					// 刷道比赛
					MmochatPropService.dealDaoActivity(me, dao);

					int trueDao = MmochatBattleService.getRealDao(me, dao);
					me.addDao(trueDao);
					awardMsg += trueDao + "天道行、";

					// 第一格道具
					double rate = Math.random() * 100;

					// propType->机率
					Object propRate[][] = { { MmochatPropType.八卦令, 1.0 },
							{ MmochatPropType.赎罪牌, 1.0 },
							{ MmochatPropType.白水晶, 5.0 },
							{ MmochatPropType.改造石, 20.0 },
							{ MmochatPropType.混沌石, 0.5 },
							{ MmochatPropType.超级白水晶, 0.1 },
							{ MmochatPropType.超级改造石, 0.1 },
							{ MmochatPropType.粉水晶, 0.1 },
							{ MmochatPropType.金水晶, 0.1 },
							{ MmochatPropType.绿水晶, 0.1 },
							{ MmochatPropType.升级石, 0.5 },
							{ MmochatPropType.天尊令, 35.0 },
							{ MmochatPropType.驱兽令, 35.0 } };

					MmochatPropType p1Type = null;
					double curRate = 0;
					for (int i = 0; i < propRate.length; i++) {
						curRate += (Double) propRate[i][1];
						if (curRate > rate) {
							// 命中道具
							p1Type = (MmochatPropType) propRate[i][0];
							break;
						}
					}
					if (p1Type != null) {
						MmochatProp newProp = new MmochatProp(p1Type);
						newProp.setCanDeal(prop.isCanDeal());
						me.addObjectToPackage(newProp);
						awardMsg += newProp.getType().toString() + "、";
					}

					// 第二格道具
					rate = Math.random() * 100;
					p1Type = null;
					Object propRate2[][] = { { MmochatPropType.小血石, 20.0 },
							{ MmochatPropType.小血瓶, 20.0 },
							{ MmochatPropType.小法池, 20.0 },
							{ MmochatPropType.小法玲珑, 20.0 },
							{ MmochatPropType.中血石, 1.0 },
							{ MmochatPropType.中血瓶, 1.0 },
							{ MmochatPropType.中法池, 1.0 },
							{ MmochatPropType.中法玲珑, 1.0 } };
					curRate = 0;
					for (int i = 0; i < propRate2.length; i++) {
						curRate += (Double) propRate2[i][1];
						if (curRate > rate) {
							// 命中道具
							p1Type = (MmochatPropType) propRate2[i][0];
							break;
						}
					}

					if (p1Type != null) {
						MmochatProp newProp = new MmochatProp(p1Type);
						newProp.setCanDeal(prop.isCanDeal());
						me.addObjectToPackage(newProp);
						awardMsg += newProp.getType().toString() + "、";
					}

					msgMap.put(1, "您打开新年大礼包获得了" + awardMsg + "祝您新年快乐!");
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;

			}
			case 圣诞礼物: {
				if (propUser instanceof MmochatPlayer) {
					addPropCost = false;
					if (!propOwner.hasEnoughPackageSpace(2)) {
						msgMap.put(0, "您的包裹太满,请先清理出两个空位!");
						return msgMap;
					}
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					MmochatPlayer me = (MmochatPlayer) propUser;
					String awardMsg = "";
					// 元宝1000 0.1%
					if (MmochatUtil.isInPercent(0.1)) {
						me.addBig_money(1000);
						MmochatStatisticsService.addBigMoneyEarn(
								MmochatBigMoneyEarnType.圣诞礼物, 1000);
						awardMsg += MmochatUtil.wrapColor("1000元宝",
								Color.yellow);
						systemMsg = MmochatUtil.wrapColor(me.getName(),
								Color.yellow)
								+ "得到圣诞老人的祝福,打开圣诞礼物时喜得"
								+ MmochatUtil.wrapColor("1000元宝", Color.yellow)
								+ "!";
					}

					// 金钱5000 100%
					int money = MmochatUtil.getRandomValue(3000, 7000);
					me.addAndUpdateSmall_money(money);
					MmochatStatisticsService.addSmallMoneyEarn(
							MmochatSmallMoneyEarnType.圣诞礼物, money);
					awardMsg += MmochatUtil.getColorMoney(money) + "文钱、";

					// 道行2年 100%
					int dao = MmochatUtil.getRandomValue(365, 1095);
					// 刷道比赛
					MmochatPropService.dealDaoActivity(me, dao);

					int trueDao = MmochatBattleService.getRealDao(me, dao);
					me.addDao(trueDao);
					awardMsg += trueDao + "天道行、";

					// 第一格道具
					// 虚无水 5%
					// 镇定剂 5%
					// 防冻剂 5%
					// 八卦令 1%
					// 赎罪牌 1%
					double rate = Math.random() * 100;
					MmochatPropType p1Type = null;
					if (rate < 5) {
						p1Type = MmochatPropType.虚无水;
					} else if (rate < 5 + 5) {
						p1Type = MmochatPropType.镇定剂;
					} else if (rate < 5 + 5 + 5) {
						p1Type = MmochatPropType.防冻剂;
					} else if (rate < 5 + 5 + 5 + 1) {
						p1Type = MmochatPropType.八卦令;
					} else if (rate < 5 + 5 + 5 + 1 + 1) {
						p1Type = MmochatPropType.赎罪牌;
					}
					if (p1Type != null) {
						MmochatProp newProp = new MmochatProp(p1Type);
						newProp.setCanDeal(prop.isCanDeal());
						me.addObjectToPackage(newProp);
						awardMsg += newProp.getType().toString() + "、";
					}

					// 第二格道具
					// 白水晶 5%
					// 改造石 20%
					// 混沌石 0.5%
					// 超级白水晶 0.1%
					// 超级改造石 0.1%
					// 粉水晶 0.1%
					// 金水晶 0.1%
					// 绿水晶 0.1%
					// 升级石 0.5%
					rate = Math.random() * 100;
					p1Type = null;
					if (rate < 5) {
						p1Type = MmochatPropType.白水晶;
					} else if (rate < 5 + 20) {
						p1Type = MmochatPropType.改造石;
					} else if (rate < 5 + 20 + 0.5) {
						p1Type = MmochatPropType.混沌石;
					} else if (rate < 5 + 20 + 0.5 + 0.1) {
						p1Type = MmochatPropType.超级白水晶;
					} else if (rate < 5 + 20 + 0.5 + 0.1 + 0.1) {
						p1Type = MmochatPropType.超级改造石;
					} else if (rate < 5 + 20 + 0.5 + 0.1 + 0.1 + 0.1) {
						p1Type = MmochatPropType.粉水晶;
					} else if (rate < 5 + 20 + 0.5 + 0.1 + 0.1 + 0.1 + 0.1) {
						p1Type = MmochatPropType.金水晶;
					} else if (rate < 5 + 20 + 0.5 + 0.1 + 0.1 + 0.1 + 0.1
							+ 0.1) {
						p1Type = MmochatPropType.绿水晶;
					} else if (rate < 5 + 20 + 0.5 + 0.1 + 0.1 + 0.1 + 0.1
							+ 0.1 + 0.5) {
						p1Type = MmochatPropType.升级石;
					}
					if (p1Type != null) {
						MmochatProp newProp = new MmochatProp(p1Type);
						newProp.setCanDeal(prop.isCanDeal());
						me.addObjectToPackage(newProp);
						awardMsg += newProp.getType().toString() + "、";
					}

					msgMap.put(1, "您打开圣诞礼物获得了" + awardMsg + "祝您圣诞愉快!");
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;

			}
			case 老用户回归大礼包: {
				if (propUser instanceof MmochatPlayer) {
					addPropCost = false;
					// 打开后可获得1个超级后悔药、1个超级洗髓丹、改4白装备一套、会员周卡、
					// 小血瓶、小法瓶、低于人物10级的树妖宝宝，所有奖励都是赠品。
					if (!propOwner.hasEnoughPackageSpace(9)) {
						msgMap.put(0, "您的包裹太满,请先清理出9个空位!");
						return msgMap;
					}
					if (propOwner.isPetFull()) {
						msgMap.put(0, "您携带的宠物已达上限,请先将部分宠物存放到仓库!");
						return msgMap;
					}
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					MmochatPlayer me = (MmochatPlayer) propUser;
					// 赠送改4白装备一套
					int equipLevel = me.getLevel() / 10 * 10;
					int modifyLevel = 4;
					MmochatEquip equip = MmochatEquipService.createRandomEquip(
							true, MmochatEquipType.头盔, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.武器, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.衣服, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					equip = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.鞋子, equipLevel,
							MmochatEquipQualityType.白装);
					equip.setEquipModifyLevel(modifyLevel);
					equip.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(equip,
							false));

					// 赠品:1个超级后悔药、1个超级洗髓丹、会员周卡、小血瓶、小法玲珑
					MmochatProp newProp = new MmochatProp(MmochatPropType.超级后悔药);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					newProp = new MmochatProp(MmochatPropType.超级洗髓丹);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					newProp = new MmochatProp(MmochatPropType.会员周卡);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					newProp = new MmochatProp(MmochatPropType.小血瓶);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					newProp = new MmochatProp(MmochatPropType.小法玲珑);
					newProp.setCanDeal(false);
					gridNeedUpdatePack.addGrid(me.addObjectToPackage(newProp,
							false));

					// 低于人物10级的树妖宝宝
					int petLevel = Math.max(0, me.getLevel() - 10);
					MmochatRoleType type = MmochatRoleType.树妖;
					MmochatPet pet = MmochatPetService.createPetByType(type);
					if (pet != null) {
						pet.initLevel(petLevel);
						pet.setPetType(MmochatPetType.宝宝);
						MmochatPetService.resetPetProtential(pet);
						me.addPet(pet);

						Mmochat_5_10S pack = new Mmochat_5_10S();
						pack.addPet(pet);
						MmochatUtil.sendCommonPack(me, pack);
					}
					msgMap.put(1, "您打开老用户回归大礼包获得了" + "1个超级后悔药、1个超级洗髓丹、改4白装备一套、"
							+ "1个会员周卡、1个小血瓶、1个小法瓶和" + petLevel
							+ "级的树妖宝宝!祝您玩得愉快!");
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;
			}
			case 三魂炼丹术:
			case 七魄炼丹术:
			case 妙手回春炼丹术:
			case 魂魄归位炼丹术: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;
					MmochatLifeSkillType lifeSkillType = null;
					switch (prop.getPropType()) {
					case 三魂炼丹术:
						lifeSkillType = MmochatLifeSkillType.三魂炼丹术;
						break;
					case 七魄炼丹术:
						lifeSkillType = MmochatLifeSkillType.七魄炼丹术;
						break;
					case 妙手回春炼丹术:
						lifeSkillType = MmochatLifeSkillType.妙手回春炼丹术;
						break;
					case 魂魄归位炼丹术:
						lifeSkillType = MmochatLifeSkillType.魂魄归位炼丹术;
						break;
					}
					MmochatLifeSkill skill = me.getLifeSkill(lifeSkillType);
					if (skill != null) {
						msgMap.put(0, "您已经习得" + lifeSkillType.toString()
								+ "，无须再使用此道具!");
						return msgMap;
					}
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}

					// 学习此技能
					skill = new MmochatLifeSkill();
					skill.setType(lifeSkillType);
					skill.setLevel(1);
					me.addNewLifeSkill(skill);

					msgMap.put(1, "您学会了<" + lifeSkillType.toString()
							+ ">，您可以按6键回门派，找门派掌门进一步了解此炼丹术!");

				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;
			}
			case 三魂炼丹心经:
			case 七魄炼丹心经:
			case 妙手回春炼丹心经:
			case 魂魄归位炼丹心经: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;
					MmochatLifeSkillType lifeSkillType = null;
					switch (prop.getPropType()) {
					case 三魂炼丹心经:
						lifeSkillType = MmochatLifeSkillType.三魂炼丹术;
						break;
					case 七魄炼丹心经:
						lifeSkillType = MmochatLifeSkillType.七魄炼丹术;
						break;
					case 妙手回春炼丹心经:
						lifeSkillType = MmochatLifeSkillType.妙手回春炼丹术;
						break;
					case 魂魄归位炼丹心经:
						lifeSkillType = MmochatLifeSkillType.魂魄归位炼丹术;
						break;
					}
					MmochatLifeSkill skill = me.getLifeSkill(lifeSkillType);
					if (skill == null) {
						msgMap.put(0, "您尚未习得" + lifeSkillType.toString()
								+ "，您可以按9键到商城-装备法宝中购买相应的炼丹术!");
						return msgMap;
					}
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}

					int addExp = 0;
					if (MmochatUtil.isInPercent(0.3)) {
						addExp = 1000;
					} else {
						// 80-120
						addExp = MmochatUtil.getRandomValue(80, 120);
					}
					// 增加技能经验
					skill.addExp(addExp);

					msgMap.put(1, "您获得了"
							+ MmochatUtil.wrapColor(addExp + "点", Color.yellow)
							+ "<" + lifeSkillType.toString() + ">经验!");

				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;
			}
			case 横扫千军秘籍: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;
					MmochatSpecialSkill skill = me
							.getSpecialSkill(MmochatSpecialSkillType.横扫千军);
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					if (skill != null && skill.getLevel() > 0) {
						// 已学过此技能，增加100点经验
						skill.addExp(100);
						msgMap.put(1, "您的<横扫千军>技能增加了100点经验，当前技能经验为"
								+ skill.getExp() + "点!");
					} else {
						// 学习此技能
						skill = new MmochatSpecialSkill();
						skill.setType(MmochatSpecialSkillType.横扫千军);
						skill.setLevel(1);
						me.addNewSpecialSkill(skill);

						msgMap.put(1, "您学会了<横扫千军>，您可以到江宁找<海慧法师>进行查询此技能!");
					}
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;
			}
			case 一击必杀秘籍: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;
					MmochatSpecialSkill skill = me
							.getSpecialSkill(MmochatSpecialSkillType.一击必杀);
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					if (skill != null && skill.getLevel() > 0) {
						// 已学过此技能，增加100点经验
						skill.addExp(100);
						msgMap.put(1, "您的<一击必杀>技能增加了100点经验，当前技能经验为"
								+ skill.getExp() + "点!");
					} else {
						skill = new MmochatSpecialSkill();
						skill.setType(MmochatSpecialSkillType.一击必杀);
						skill.setLevel(1);
						me.addNewSpecialSkill(skill);

						msgMap.put(1, "您学会了<一击必杀>，您可以到江宁找<海慧法师>进行查询此技能!");
					}
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;
			}
			case 道法无边秘籍: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;
					MmochatSpecialSkill skill = me
							.getSpecialSkill(MmochatSpecialSkillType.道法无边);
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					if (skill != null && skill.getLevel() > 0) {
						// 已学过此技能，增加100点经验
						skill.addExp(100);
						msgMap.put(1, "您的<道法无边>技能增加了100点经验，当前技能经验为"
								+ skill.getExp() + "点!");
					} else {
						skill = new MmochatSpecialSkill();
						skill.setType(MmochatSpecialSkillType.道法无边);
						skill.setLevel(1);
						me.addNewSpecialSkill(skill);

						msgMap.put(1, "您学会了<道法无边>，您可以到江宁找<海慧法师>进行查询此技能!");
					}
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;
			}
			case 性别变更水: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;
					if (me.hasWife()) {
						msgMap.put(0, "您当前还有配偶，无法使用此道具!请先离婚再使用!");
						return msgMap;
					}

					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}

					MmochatRoleType oldRoleType = me.getRoleType();
					MmochatRoleType newRoleType = null;
					int oldSex = me.getSexual();
					int newSex = me.getSexual();
					int oldFriendListBmp = me.getBmpId();
					int friendListBmp = 0;
					if (me.getSexual() == 0 && me.getFamily().getValue() == 0) {
						newSex = 1;
						newRoleType = MmochatRoleType.阐教女;
						friendListBmp = MmochatConstant.BMP_GIRLTAG;
					} else if (me.getSexual() == 1
							&& me.getFamily().getValue() == 0) {
						newSex = 0;
						newRoleType = MmochatRoleType.阐教男;
						friendListBmp = MmochatConstant.BMP_BOYTAG;
					} else if (me.getSexual() == 0
							&& me.getFamily().getValue() == 1) {
						newSex = 1;
						newRoleType = MmochatRoleType.人教女;
						friendListBmp = MmochatConstant.BMP_GIRLTAG;
					} else if (me.getSexual() == 1
							&& me.getFamily().getValue() == 1) {
						newSex = 0;
						newRoleType = MmochatRoleType.人教男;
						friendListBmp = MmochatConstant.BMP_BOYTAG;
					} else if (me.getSexual() == 0
							&& me.getFamily().getValue() == 2) {
						newSex = 1;
						newRoleType = MmochatRoleType.截教女;
						friendListBmp = MmochatConstant.BMP_GIRLTAG;
					} else if (me.getSexual() == 1
							&& me.getFamily().getValue() == 2) {
						newSex = 0;
						newRoleType = MmochatRoleType.截教男;
						friendListBmp = MmochatConstant.BMP_BOYTAG;
					}

					// 清除门派技能，变更：roleType，family
					me.setSexual(newSex);
					me.setRoleType(newRoleType);
					me.setBmpId(friendListBmp);

					// 保存数据库:性别、图片
					try {
						MmochatDao.changeSex(me);
					} catch (Exception e) {
						e.printStackTrace();
						prop.addOverlapNum(1);
						grid.setObject(prop);
						me.setSexual(oldSex);
						me.setRoleType(oldRoleType);
						me.setBmpId(oldFriendListBmp);
						msgMap.put(0, "服务器忙，请稍候再试!");
						return msgMap;
					}

					// 下发通知消息:退出游戏重新进入才能生效
					String sysInfo = MmochatUtil.wrapColor(me.getName(),
							Color.green)
							+ "使用了" + MmochatPropType.性别变更水.toString() + "!";
					MmochatChatService.sendSystemMsg(sysInfo);
					msgMap.put(1, "使用成功!"
							+ MmochatUtil.wrapColor("请退出游戏重新进入，完成性别变更!",
									Color.magenta));
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;
			}
			case 脱胎换骨水: {
				if (propUser instanceof MmochatPlayer) {
					MmochatPlayer me = (MmochatPlayer) propUser;

					CreateTlvWin tlv = new CreateTlvWin();
					tlv.setWinType(WinType.List);
					tlv.setTitle("请选择新的门派");
					tlv.setRightName("取消");
					tlv.setLeftName("加入");
					tlv.setWinHeight(208);
					tlv.addRightTLV(new CloseWinTLV());

					for (MmochatFamilyType family : MmochatFamilyType.values()) {
						tlv.addItemEvent(family.getName(), new ClearDataTLV(),
								new AddDataTLV((int) family.getValue()));
					}
					tlv.addLeftTLV(new AddDataTLV((int) gridId));
					tlv.addLeftTLV(new SendDataTLV(MmochatConstant
							.getClientModuleId(),
							MmochatMain.getModuleInstID(),
							MmochatConstant.MSGCODE_MMOCHAT_C_13_22, (int) me
									.getRoleId()));
					ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
					wait.setShowCancel(false);
					tlv.addLeftTLV(wait);
					msgMap.put(2, (TLVStructure) tlv);
					addPropCost = false;
					return msgMap;
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
			}
			case 物攻强化灵气丹: {
				if (propUser instanceof MmochatPet) {
					MmochatPet pet = (MmochatPet) propUser;
					if (pet.getBorrowFromRoleId() != null) {
						msgMap.put(0, "这个宠物是向他人借来的，无法使用此道具!");
						return msgMap;
					}
					if (pet.getPetType() == MmochatPetType.野生) {
						msgMap.put(0, "此道具不能给野生类型的宠物使用!");
						return msgMap;
					}
					// 判断是否已经强化满
					if (pet.getPhysicalExtra() >= MmochatConstant.maxPetExtraValue) {
						msgMap.put(0, "此宠物的物攻强化灵气值已达上限值"
								+ MmochatConstant.maxPetExtraValue
								+ "点，无法继续使用此道具!");
						return msgMap;
					}

					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					int add = 0;
					if (MmochatUtil.isInPercent(1)) {
						add = 30;
					} else {
						add = MmochatUtil.getRandomValue(1, 5);
					}
					pet.addPhysicalExtra(add);
					double addPercent = 10 * pet.getPhysicalExtra()
							/ MmochatConstant.petExtraValuePerEffect / 10.0;
					msgMap.put(1, "您的宠物获得了" + add + "点物攻强化灵气，当前物攻强化总灵气为"
							+ pet.getPhysicalExtra() + "点，宠物物伤提升" + addPercent
							+ "%，物攻成长及物攻成长上限提升" + addPercent + "%");
				} else {
					msgMap.put(0, "此道具只能给宠物使用!请打开宠物信息面板,点击<喂养>使用!");
					return msgMap;
				}
				break;

			}
			case 速度强化灵气丹: {
				if (propUser instanceof MmochatPet) {
					MmochatPet pet = (MmochatPet) propUser;
					if (pet.getBorrowFromRoleId() != null) {
						msgMap.put(0, "这个宠物是向他人借来的，无法使用此道具!");
						return msgMap;
					}
					if (pet.getPetType() == MmochatPetType.野生) {
						msgMap.put(0, "此道具不能给野生类型的宠物使用!");
						return msgMap;
					}
					// 判断是否已经强化满
					if (pet.getSpeedExtra() >= MmochatConstant.maxPetSpeedExtraValue) {
						msgMap.put(0, "此宠物的速度强化灵气值已达上限值"
								+ MmochatConstant.maxPetExtraValue
								+ "点，无法继续使用此道具!");
						return msgMap;
					}

					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					int add = 0;
					if (MmochatUtil.isInPercent(1)) {
						add = 30;
					} else {
						add = MmochatUtil.getRandomValue(1, 5);
					}
					pet.addSpeedExtra(add);
					double addPercent = 10 * pet.getSpeedExtra()
							/ MmochatConstant.petExtraValuePerEffect / 10.0;
					msgMap.put(1, "您的宠物获得了" + add + "点速度强化灵气，当前速度强化总灵气为"
							+ pet.getSpeedExtra() + "点，宠物速度提升" + addPercent
							+ "%，速度成长及速度成长上限提升" + addPercent + "%");
				} else {
					msgMap.put(0, "此道具只能给宠物使用!请打开宠物信息面板,点击<喂养>使用!");
					return msgMap;
				}
				break;
			}
			case 法攻强化灵气丹: {
				if (propUser instanceof MmochatPet) {
					MmochatPet pet = (MmochatPet) propUser;
					if (pet.getBorrowFromRoleId() != null) {
						msgMap.put(0, "这个宠物是向他人借来的，无法使用此道具!");
						return msgMap;
					}
					if (pet.getPetType() == MmochatPetType.野生) {
						msgMap.put(0, "此道具不能给野生类型的宠物使用!");
						return msgMap;
					}
					// 判断是否已经强化满
					if (pet.getMagicExtra() >= MmochatConstant.maxPetExtraValue) {
						msgMap.put(0, "此宠物的法攻强化灵气值已达上限值"
								+ MmochatConstant.maxPetExtraValue
								+ "点，无法继续使用此道具!");
						return msgMap;
					}

					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					int add = 0;
					if (MmochatUtil.isInPercent(1)) {
						add = 30;
					} else {
						add = MmochatUtil.getRandomValue(1, 5);
					}
					pet.addMagicExtra(add);
					double addPercent = 10 * pet.getMagicExtra()
							/ MmochatConstant.petExtraValuePerEffect / 10.0;
					msgMap.put(1, "您的宠物获得了" + add + "点法攻强化灵气，当前法攻强化总灵气为"
							+ pet.getMagicExtra() + "点，宠物法伤提升" + addPercent
							+ "%，法攻成长及法攻成长上限提升" + addPercent + "%");
				} else {
					msgMap.put(0, "此道具只能给宠物使用!请打开宠物信息面板,点击<喂养>使用!");
					return msgMap;
				}
				break;

			}
			case 血量强化灵气丹: {
				if (propUser instanceof MmochatPet) {
					MmochatPet pet = (MmochatPet) propUser;
					if (pet.getBorrowFromRoleId() != null) {
						msgMap.put(0, "这个宠物是向他人借来的，无法使用此道具!");
						return msgMap;
					}
					if (pet.getPetType() == MmochatPetType.野生) {
						msgMap.put(0, "此道具不能给野生类型的宠物使用!");
						return msgMap;
					}
					// 判断是否已经强化满
					if (pet.getBloodExtra() >= MmochatConstant.maxPetExtraValue) {
						msgMap.put(0, "此宠物的血量强化灵气值已达上限值"
								+ MmochatConstant.maxPetExtraValue
								+ "点，无法继续使用此道具!");
						return msgMap;
					}

					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					int add = 0;
					if (MmochatUtil.isInPercent(1)) {
						add = 30;
					} else {
						add = MmochatUtil.getRandomValue(1, 5);
					}
					pet.addBloodExtra(add);
					double addPercent = 10 * pet.getBloodExtra()
							/ MmochatConstant.petExtraValuePerEffect / 10.0;
					msgMap.put(1, "您的宠物获得了" + add + "点血量强化灵气，当前血量强化总灵气为"
							+ pet.getBloodExtra() + "点，宠物血量提升" + addPercent
							+ "%，血量成长及血量成长上限提升" + addPercent + "%");
				} else {
					msgMap.put(0, "此道具只能给宠物使用!请打开宠物信息面板,点击<喂养>使用!");
					return msgMap;
				}
				break;
			}
			case 借条: {
				msgMap.put(0, "当你向他人借物品或宠物时，在交易时将此道具交易给对方!\n"
						+ "如果他人向你借，则你应该让对方同时给你一个借条。");
				return msgMap;
			}
			case 节日锦囊: {
				if (propUser instanceof MmochatPlayer) {
					if (!propOwner.hasEnoughPackageSpace(1)) {
						msgMap.put(0, "您的包裹已满,请先清理出一个空位!");
						return msgMap;
					}
					if (propOwner.isPetFull()) {
						msgMap.put(0, "打开节日锦囊前，携带宠物数不能超过3个，请先将部分宠物存到仓库!");
						return msgMap;
					}
					if (prop.isCanOverlap()) {
						prop.delOverlapNum(1);
						if (prop.getOverlapNum() <= 0) {
							grid.setObject(null);
						}
					} else {
						prop.delAmount(1);
						if (prop.getCurPropAmount() <= 0) {
							grid.setObject(null);
						}
					}
					MmochatPlayer me = (MmochatPlayer) propUser;
					if (MmochatUtil.isInPercent(50)) {
						// 50%机率出强化灵气丹
						if (MmochatUtil.isInPercent(0.005)) {
							// 中神兽
							MmochatRoleType[] list = new MmochatRoleType[] {
									MmochatRoleType.高力玄武, MmochatRoleType.通灵玄武,
									MmochatRoleType.铁血玄武, MmochatRoleType.幻影玄武 };
							int itemIndex = MmochatUtil
									.getRandomValue(list.length);
							MmochatRoleType type = list[itemIndex];
							MmochatPet pet = MmochatPetService
									.createPetByType(type);
							if (pet != null) {
								me.addPet(pet);
								try {
									MmochatDao.updateRolePets(me);
								} catch (Exception e) {
									e.printStackTrace();
								}

								Mmochat_5_10S pack = new Mmochat_5_10S();
								pack.addPet(pet);
								MmochatUtil.sendCommonPack(me, pack);

								String sysInfo = MmochatUtil.wrapColor(me
										.getName(), Color.green)
										+ "打开节日锦囊，意外的得到一个"
										+ MmochatUtil
												.wrapColor(
														pet.getPetTypeName(),
														Color.yellow)
										+ "!朋友们快找他请客呀~";
								sysInfo = MmochatUtil.wrapColor(sysInfo,
										Color.red);
								MmochatChatService.sendSystemMsg(sysInfo);

								String myInfo1 = "恭喜恭喜!您打开节日锦囊，获得一个"
										+ MmochatUtil
												.wrapColor(
														pet.getPetTypeName(),
														Color.yellow)
										+ "，快按0键打开宠物信息看看吧!";
								myInfo1 = MmochatUtil.wrapColor(myInfo1,
										Color.red);
								MmochatChatService.sendSystemMsgToPerson(me,
										myInfo1);
								msgMap.put(1, myInfo1);
								break;
							}
						} else {
							// 强化灵气丹
							MmochatPropType[] list = new MmochatPropType[] {
									MmochatPropType.血量强化灵气丹,
									MmochatPropType.物攻强化灵气丹,
									MmochatPropType.法攻强化灵气丹,
									MmochatPropType.速度强化灵气丹 };
							int itemIndex = MmochatUtil
									.getRandomValue(list.length);
							MmochatPropType awardPropType = list[itemIndex];
							MmochatProp newProp = new MmochatProp(awardPropType);
							me.addObjectToPackage(newProp);
							msgMap.put(1, "您打开节日锦囊获得了一个"
									+ newProp.getType().toString() + "!");
							break;
						}
					} else {
						// 50%机率和普通锦囊相同
						// propType->机率
						Object propRate[][] = { { MmochatPropType.传送符, 0.02 },
								{ MmochatPropType.龙涎香, 0.02 },
								{ MmochatPropType.中血石, 0.02 },
								{ MmochatPropType.小血石, 0.03 },
								{ MmochatPropType.中法池, 0.02 },
								{ MmochatPropType.小法池, 0.03 },
								{ MmochatPropType.中血玲珑, 0.02 },
								{ MmochatPropType.小血玲珑, 0.03 },
								{ MmochatPropType.中法玲珑, 0.02 },
								{ MmochatPropType.小法玲珑, 0.03 },
								{ MmochatPropType.混沌石, 0.01 },
								{ MmochatPropType.超级改造石, 0.01 },
								{ MmochatPropType.喇叭, 0.04 },
								{ MmochatPropType.成长丹, 0.02 },
								{ MmochatPropType.超级成长丹, 0.01 },
								{ MmochatPropType.轮回水, 0.05 },
								{ MmochatPropType.迟滞水, 0.02 },
								{ MmochatPropType.八卦令, 0.02 },
								{ MmochatPropType.银联卡, 0.02 },
								{ MmochatPropType.赎罪牌, 0.01 },
								{ MmochatPropType.后悔药, 0.05 },
								{ MmochatPropType.防冻剂, 0.05 },
								{ MmochatPropType.镇定剂, 0.05 },
								{ MmochatPropType.虚无水, 0.05 } };
						double rate = Math.random();
						double curRate = 0;
						boolean hit = false;
						for (int i = 0; i < propRate.length; i++) {
							curRate += (Double) propRate[i][1];
							if (curRate > rate) {
								// 命中道具
								MmochatProp newProp = new MmochatProp(
										(MmochatPropType) propRate[i][0]);
								me.addObjectToPackage(newProp);
								msgMap.put(1, "您打开节日锦囊获得了一个"
										+ newProp.getType().toString() + "!");
								hit = true;
								break;
							}
						}
						if (hit) {
							break;
						}
						// 战绩300点
						curRate += 0.1;
						if (curRate > rate) {
							// 命中战绩
							me.addZhanji(300);
							msgMap.put(1, "您打开节日锦囊获得了300点战绩");
							break;
						}

						// 30000游戏币
						curRate += 0.1;
						if (curRate > rate) {
							me.addAndUpdateSmall_money(30000);
							MmochatStatisticsService.addSmallMoneyEarn(
									MmochatSmallMoneyEarnType.节日锦囊, 30000);
							msgMap.put(1, "您打开节日锦囊获得了"
									+ MmochatUtil.getColorMoney(30000) + "文钱");
							break;
						}

						// 其它的给道行300天
						// 刷道比赛
						MmochatPropService.dealDaoActivity(me, 300);

						int trueDao = MmochatBattleService.getRealDao(me, 300);
						me.addDao(trueDao);
						msgMap.put(1, "您打开节日锦囊获得了" + trueDao + "天道行");
					}
				} else {
					msgMap.put(0, "此道具只能给人物使用!");
					return msgMap;
				}
				break;
			}
			default:
				msgMap.put(0, "没有找到此道具!");
				break;
			}
		}
		if (msgMap.get(0) == null) {
			try {
				// 放入队列中
				if (!needToSavePropSqlPlayerQueue.contains(propOwner)
						&& !MmochatGmService.isSystemExit()) {
					needToSavePropSqlPlayerQueue.add(propOwner);
				}
				if (otherUser != null) {
					if (!needToSavePropSqlPlayerQueue.contains(otherUser)
							&& !MmochatGmService.isSystemExit()) {
						needToSavePropSqlPlayerQueue.add(otherUser);
					}
				}
				gridNeedUpdatePack.addGrid(grid);
				MmochatUtil.sendCommonPack(propOwner, gridNeedUpdatePack);
				// 更新人物状态
				Mmochat_1_16S pack2 = new Mmochat_1_16S();
				pack2.setMe(propOwner);
				MmochatUtil.sendCommonPack(propOwner, pack2);
				if (addPropCost) {
					MmochatStatisticsService.addPropCost(propType, 1);
				}
			} catch (Exception e) {
				e.printStackTrace();
				// MmochatMainService.setPlayerNewValue(oldMe);
				// if (otherUser != null) {
				// MmochatMainService.setPlayerNewValue(otherUserBak);
				// }
				msgMap.put(0, "服务器忙,请稍候使用此道具!");
				return msgMap;
			}
			if (systemMsg != null) {
				MmochatChatService.sendSystemMsg(systemMsg);
			}
		}
		return msgMap;
	}

	// 13.7 使用改名卡
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_7(SkymobiHandler handler,
			Mmochat_13_7C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatPackageGrid grid;
		MmochatCommonObject prop;
		String newName;
		synchronized (me) {
			grid = me.getMyPackage().get(req.getGridId());
			if (grid == null) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您没有<江湖名号>道具,无法改名!");
			}
			prop = grid.getObject();
			if (prop == null || prop.getPropType() != MmochatPropType.江湖名号
					|| prop.getOverlapNum() <= 0) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您没有<江湖名号>道具,无法改名!");
			}
			newName = req.getNewName();
			if (newName.length() > MmochatConstant.maxNameLen
					|| newName.length() <= 0) {
				return MmochatUtil.msgbox(req.getHallState(), "昵称最短1个字,最长"
						+ MmochatConstant.maxNameLen + "个字!");
			}
			if (newName.equals(me.getName())) {
				return MmochatUtil.msgbox(req.getHallState(), "您现在已经叫"
						+ newName + "了,无须改名!");
			}
			if (!MmochatMainService.isRoleNameValid(newName)) {
				return MmochatUtil.msgbox(req.getHallState(),
						"新昵称中包含了不允许使用的字词符号，请重新输入!");
			}
			prop.delOverlapNum(1);
			if (prop.getOverlapNum() <= 0) {
				grid.setObject(null);
			}
			MmochatStatisticsService.addPropCost(MmochatPropType.江湖名号, 1);
		}
		try {
			MmochatDao.updateRoleName(me, newName);
		} catch (DataIntegrityViolationException e) {
			prop.addOverlapNum(1);
			grid.setObject(prop);
			return MmochatUtil.msgbox(req.getHallState(), "该角色名已存在!请使用其它名字!");
		} catch (Exception e) {
			e.printStackTrace();
			prop.addOverlapNum(1);
			grid.setObject(prop);
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候使用道具!");
		}
		MmochatChatService.sendSystemMsg(MmochatUtil.wrapColor(me.getName(),
				Color.yellow)
				+ "使用了<"
				+ prop.getType().toString()
				+ ">,将自己的名字改为"
				+ MmochatUtil.wrapColor(newName, Color.yellow));
		MmochatMainService.nameMap.remove(me.getName());
		MmochatMainService.nameMap.put(newName, me.getRoleId());
		me.setName(newName);

		Mmochat_1_10S pack = new Mmochat_1_10S();
		pack.setMe(me);
		MmochatUtil.sendCommonPack(me, pack);

		Mmochat_5_1S pack2 = new Mmochat_5_1S();
		pack2.addGrid(grid);
		MmochatUtil.sendCommonPack(me, pack2);

		return MmochatUtil
				.msgbox(req.getHallState(), "您已成功改名为" + newName + "!");
	}

	// 13.8 使用远程钱庄
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_8(SkymobiHandler handler,
			Mmochat_13_8C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		switch (req.getIndex()) {
		case 0: {
			// 存放物品
			Mmochat_12_15S pack = new Mmochat_12_15S();
			pack.setHallState(req.getHallState());
			return pack;
		}
		case 1: {
			// 取回物品
			if (MmochatNpcService.checkStorePwd(me)) {
				return null;
			}
			// 整理仓库
			MmochatStoreService.orderStorage(me);

			Mmochat_12_18S pack = new Mmochat_12_18S();
			pack.setStoredMoney(me.getStoredSmall_money());
			for (MmochatPackageGrid grid : me.getMyStorage().values()) {
				if (grid.getObject() != null) {
					pack.addGrid(grid);
				}
			}
			return pack;
		}
		case 2: {
			// 存放宠物
			Mmochat_12_23S pack = new Mmochat_12_23S();
			pack.setHallState(req.getHallState());
			return pack;
		}
		case 3: {
			// 取回宠物
			if (MmochatNpcService.checkStorePwd(me)) {
				return null;
			}
			if (me.getStoredPets().size() == 0) {
				return MmochatUtil.msgbox(req.getHallState(), "您没有寄存的宠物!");
			}
			CreateTlvWin tlv = MmochatStoreService.getStoredPetList(me);
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		default:
			break;
		}
		return null;
	}

	// 13.2 查看杂货信息
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_2(SkymobiHandler handler,
			Mmochat_13_2C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatPropType propType = MmochatPropType.get(req.getPropKey());

		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.Text);
		tlv.setRightName("返回");
		tlv.setTitle(propType.toString());
		tlv.setWinHeight(188);
		tlv.addRightTLV(new CloseWinTLV());
		String content = propType.getInfo();
		tlv.setContent(new Text(content));
		return MmochatUtil.tlvResponse(req.getHallState(), tlv);
	}

	// 生成商城tlv
	public static CtrlTLVStructureRequest getShopTlv(int hallState, int roleId) {
		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.List);
		tlv.setLeftName("进入");
		tlv.setRightName("返回");
		tlv.setTitle("商城");
		tlv.setWinHeight(208);
		tlv.addRightTLV(new CloseWinTLV());
		for (MmochatShopClassType shop : MmochatShopClassType.values()) {
			if (shop == MmochatShopClassType.打折促销
					&& !MmochatConstant.isShopDiscountActivityOpen()) {
				continue;
			}
			if (shop == MmochatShopClassType.限时出售 && !isTodayLimitSellOpen()) {
				continue;
			}
			if (shop == MmochatShopClassType.刷道比赛
					&& (daoActivityInfo == null || daoActivityInfo.getState() == MmochatPayLotteryState.活动结束)) {
				continue;
			}
			String item = shop.toString();
			if (shop.getColor() != null) {
				item = MmochatUtil.wrapColor(item, shop.getColor());
			}
			if (shop.getBmpId() != null) {
				tlv.addItemEvent(shop.getBmpId(), item, new ClearDataTLV(),
						new AddDataTLV((int) shop.getValue()));
			} else {
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) shop.getValue()));
			}
		}
		tlv.addLeftTLV(new AddDataTLV((int) MmochatConstant.shopClassVersion));
		tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_13_4, (int) roleId));
		tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

		CtrlTLVStructureRequest pack = new CtrlTLVStructureRequest(hallState,
				new CloseWinTLV(MmochatConstant.TLV_WIN_SHOPLIST), tlv);
		pack.setSrcId(MmochatMain.getModuleInstID());
		pack.setDstId(MmochatConstant.getClientModuleId());
		pack.setMsgCode(MmochatConstant.MSGCODE_MMOCHAT_S_13_3);
		return pack;
	}

	// 获取元宝充值页面
	public static CreateTlvWin getPaymentPage(MmochatPlayer me) {
		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.Text);
		tlv.setLeftName("兑换");
		tlv.setRightName("返回");
		tlv.setTitle("兑换元宝");
		tlv.setWinHeight(208);
		tlv.setWinId(MmochatConstant.TLV_WIN_PAYMENT);
		tlv.addRightTLV(new CloseWinTLV(MmochatConstant.TLV_WIN_PAYMENT));
		// TODO:充值说明
		int kbRest = CurrService.handleQueryCurrency(me.getSkyId());
		String content = MmochatUtil.wrapColor("兑换规则:\n100K币="
				+ MmochatConstant.getExchangeRate()
				+ "元宝\n可以兑换任意数量的K币，但不能超过20万\n\n", Color.green);
		if (kbRest != -1) {
			content += MmochatUtil.wrapColor("您当前拥有:\nK币：" + kbRest + "\n元宝:"
					+ me.getBig_money(), Color.yellow);
		}
		tlv.setContent(new Text(content));
		// 充值输入框
		CreateEditBoxTLV edit = new CreateEditBoxTLV();
		edit.setTitle("请输入要兑换的K币数量!");
		edit.setLeftName("兑换");
		edit.setRightName("取消");
		edit.setContentLenMax(8);
		edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
		edit.setInputType(CreateEditBoxTLV.INPUT_NUM << 4);
		edit.addLeftTLV(new ClearDataTLV());
		edit.addLeftTLV(new AddEditBoxTLV());
		edit.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_13_6, (int) me.getRoleId()));
		ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
		wait.setShowCancel(false);
		edit.addLeftTLV(wait);
		tlv.addLeftTLV(edit);

		return tlv;
	}

	// 获取抢便宜活动页面
	public static CreateTlvWin getDiscountPage(MmochatPlayer me) {
		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.Text);
		tlv.setLeftName("购买");
		tlv.setRightName("返回");
		tlv.setTitle(MmochatShopClassType.打折促销.toString());
		tlv.setWinHeight(208);
		tlv.setWinId(MmochatConstant.TLV_WIN_DISCOUNT);
		tlv.addRightTLV(new CloseWinTLV(MmochatConstant.TLV_WIN_DISCOUNT));

		String content = "";
		MmochatPropType propType = MmochatConstant.getDiscountPropType();
		if (propType == null || !MmochatConstant.isShopDiscountActivityOpen()) {
			content += "活动尚未开始!";
		} else {
			content += MmochatUtil.wrapColor("--今日促销道具--", Color.yellow);
			content += "\n" + MmochatUtil.wrapIcon(propType.getBmpId())
					+ MmochatUtil.wrapColor(propType.toString(), Color.cyan);
			int oldPrice = propType.getPrice();
			content += "\n原价:" + oldPrice + "元宝";
			// 1折到8.8折
			int min = (int) Math.max(1, oldPrice * 0.1);
			int max = (int) Math.max(1, oldPrice * 0.88);
			String sellInfo = "\n现价:" + min + "元宝~" + max + "元宝随机";
			content += MmochatUtil.wrapColor(sellInfo, Color.magenta);
			content += MmochatUtil.wrapColor("\n\n--活动说明--", Color.yellow);
			content += "\n1、本活动为临时活动，开启时间请关注游戏内公告!";
			content += "\n2、价格从1折到8.8折随机!";
			content += "\n3、活动时间为12:00至24:00!";
		}

		tlv.setContent(new Text(content));

		tlv.addLeftTLV(new ClearDataTLV());
		tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_13_15, (int) me.getRoleId()));
		ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
		wait.setShowCancel(false);
		tlv.addLeftTLV(wait);
		return tlv;
	}

	// 13.4 查看子商城
	@SuppressWarnings("deprecation")
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_4(SkymobiHandler handler,
			Mmochat_13_4C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (MmochatMain.serverType == MmochatServerType.跨服战服务器) {
			return MmochatUtil.msgbox(req.getHallState(), "跨服区内无法进行此操作!");
		}
		if (MmochatConstant.shopClassVersion != req.getVersion()) {
			return MmochatUtil.msgbox(req.getHallState(), "您的版本过旧,请退出游戏重新进入!");
		}
		MmochatShopClassType shop = MmochatShopClassType.get(req.getKey());
		if (shop == null) {
			return MmochatUtil.msgbox(req.getHallState(), "此功能暂不开放!");
		}

		switch (shop) {
		case 补血补蓝:
		case 特色道具:
		case 装备法宝:
		case 功能道具:
		case 限时出售: {
			// 终端商城一页只能显示28个道具
			Mmochat_13_4S pack = new Mmochat_13_4S();
			pack.setHallState(req.getHallState());
			pack.setShopType(MmochatShopType.元宝商店);
			pack.setVersion(MmochatConstant.shopClassVersion);
			pack.setUseInputBox(true);
			pack.setTitle(shop.toString());
			pack.setMoney((int) me.getBig_money());
			pack.setObjType(MmochatObjectType.道具);

			MmochatPropType[] propList = null;
			if (shop == MmochatShopClassType.补血补蓝) {
				propList = new MmochatPropType[] { MmochatPropType.小血石,
						MmochatPropType.中血石, MmochatPropType.大血石,
						MmochatPropType.小法池, MmochatPropType.中法池,
						MmochatPropType.大法池, MmochatPropType.小血瓶,
						MmochatPropType.中血瓶, MmochatPropType.大血瓶,
						MmochatPropType.小法玲珑, MmochatPropType.中法玲珑,
						MmochatPropType.大法玲珑 };
			} else if (shop == MmochatShopClassType.功能道具) {
				propList = new MmochatPropType[] { MmochatPropType.飞羽,
						MmochatPropType.传送符, MmochatPropType.照妖镜,
						MmochatPropType.急急如律令, MmochatPropType.超级急急如律令,
						MmochatPropType.特级急急如律令, MmochatPropType.顶级急急如律令,
						MmochatPropType.天尊令, MmochatPropType.道尊令,
						MmochatPropType.驱兽令, MmochatPropType.驭兽令,
						MmochatPropType.龙涎香, MmochatPropType.超级自动战斗令,
						MmochatPropType.鬼灵珠, MmochatPropType.经验冻结丹,
						MmochatPropType.经验解冻丹, MmochatPropType.练丹要术 };
			} else if (shop == MmochatShopClassType.特色道具) {
				propList = new MmochatPropType[] { MmochatPropType.会员周卡,
						MmochatPropType.会员月卡, MmochatPropType.锦囊,
						MmochatPropType.喇叭, MmochatPropType.金钱袋,
						MmochatPropType.成长丹, MmochatPropType.超级成长丹,
						MmochatPropType.血量成长丹, MmochatPropType.物攻成长丹,
						MmochatPropType.法攻成长丹, MmochatPropType.速度成长丹,
						MmochatPropType.物防成长丹, MmochatPropType.法防成长丹,
						MmochatPropType.轮回水, MmochatPropType.超级轮回水,
						MmochatPropType.迟滞水, MmochatPropType.八卦令,
						MmochatPropType.超级八卦令, MmochatPropType.银联卡,
						MmochatPropType.赎罪牌, MmochatPropType.后悔药,
						MmochatPropType.超级后悔药, MmochatPropType.洗髓丹,
						MmochatPropType.超级洗髓丹, MmochatPropType.江湖名号,
						MmochatPropType.超级炼丹剂, MmochatPropType.脱胎换骨水,
						MmochatPropType.性别变更水 };
			} else if (shop == MmochatShopClassType.装备法宝) {
				propList = new MmochatPropType[] { MmochatPropType.改造灵珠,
						MmochatPropType.套装明属性强化水晶, MmochatPropType.套装暗属性强化水晶,
						MmochatPropType.神行法宝残片, MmochatPropType.神行法宝灵气丹,
						MmochatPropType.神行法宝聚灵丹, MmochatPropType.神行法宝体力丹,
						MmochatPropType.混沌石, MmochatPropType.超级改造石,
						MmochatPropType.超级白水晶, MmochatPropType.粉水晶,
						MmochatPropType.金水晶, MmochatPropType.绿水晶,
						MmochatPropType.强化水晶, MmochatPropType.升级石,
						MmochatPropType.仙魔转换石, MmochatPropType.三魂炼丹术,
						MmochatPropType.七魄炼丹术, MmochatPropType.妙手回春炼丹术,
						MmochatPropType.魂魄归位炼丹术, MmochatPropType.借条 };
			} else if (shop == MmochatShopClassType.限时出售) {
				propList = new MmochatPropType[] { MmochatPropType.武魂石灵气池,
						MmochatPropType.节日锦囊, MmochatPropType.改造灵珠大礼包,
						MmochatPropType.改造灵珠小礼包, MmochatPropType.改造小礼包,
						MmochatPropType.改造大礼包, MmochatPropType.升级小礼包,
						MmochatPropType.升级大礼包, MmochatPropType.刷道小礼包,
						MmochatPropType.刷道大礼包, MmochatPropType.至尊大礼包,
						MmochatPropType.三魂炼丹心经, MmochatPropType.七魄炼丹心经,
						MmochatPropType.妙手回春炼丹心经, MmochatPropType.魂魄归位炼丹心经 };
			}

			for (MmochatPropType propType : propList) {
				Mmochat_13_4S.ShopObjInfo objInfo = pack.new ShopObjInfo();
				objInfo.setKey(propType.getKey());
				objInfo.setEquipLevel(0);
				objInfo.setBmpId(propType.getBmpId());
				objInfo.setSellInfo(propType.getSellInfo());
				pack.addShopObj(objInfo);
			}
			return pack;
		}
		case 打折促销: {
			if (!MmochatConstant.isShopDiscountActivityOpen()) {
				return MmochatUtil.msgbox(req.getHallState(), "打折促销今日未开启!");
			}
			CreateTlvWin tlv = getDiscountPage(me);
			return MmochatUtil.tlvResponse(req.getHallState(), new CloseWinTLV(
					MmochatConstant.TLV_WIN_DISCOUNT), tlv);
		}
		case 充值元宝: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("进入");
			tlv.setRightName("返回");
			tlv.setTitle("充值元宝");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());

			Date now = new Date();
			int hour = now.getHours();// 0-23
			if (MmochatConstant.isKBPayOpen) {
				tlv.addItemEvent("K币兑换元宝", new ClearDataTLV(), new AddDataTLV(
						(int) 1));
			}

			if (MmochatConstant.isDirectPayOpen) {
				tlv.addItemEvent("充值卡兑换元宝", new ClearDataTLV(), new AddDataTLV(
						(int) 2));
			}

			if (me.getLevel() >= 30) {
				if (MmochatGmService.isTodayDelayPayOpen()) {
					tlv.addItemEvent(MmochatUtil.wrapColor("充值卡预充值活动",
							Color.red), new ClearDataTLV(), new AddDataTLV(
							(int) 10));
					MmochatGmService.delayPayShowTimes++;
				} else {
					// TODO:活动结束后，如果此人预充过，则在此增加<我的预充值订单>查看
					boolean hasOrder = false;
					for (MmochatDelayPay pay : MmochatGmService.delayPays
							.values()) {
						if (pay.getRoleId() == me.getRoleId()) {
							if (pay.getState() != MmochatDelayPayState.创建中) {
								hasOrder = true;
								break;
							}
						}
					}
					if (hasOrder) {
						tlv.addItemEvent("我的预充值订单", new ClearDataTLV(),
								new AddDataTLV((int) 11));
					}
				}
			}

			if (MmochatConstant.isOwnBankPayOpen
					&& MmochatNpcService.famousList.get(me.getRoleId()) != null) {
				if (hour >= 10 && hour <= 17) {
					tlv.addItemEvent("邮政储蓄兑换元宝", new ClearDataTLV(),
							new AddDataTLV((int) 8));
				}
			}

			tlv.addItemEvent(MmochatUtil.wrapColor("本期充值抽奖活动", Color.green),
					new ClearDataTLV(), new AddDataTLV((int) 3));

			if (MmochatConstant.isFirstPayThisMonthActivityOpen) {
				tlv.addItemEvent(MmochatUtil.wrapColor("每月首次充值卡充值豪礼",
						Color.green), new ClearDataTLV(), new AddDataTLV(
						(int) 4));
			}

			// Date now = new Date();
			// if (now.getMonth() == 1 && now.getDate() >= 4 && now.getDate() <=
			// 7) {
			// tlv.addItemEvent(MmochatUtil
			// .wrapColor("充值排行送神兽", Color.magenta),
			// new ClearDataTLV(), new AddDataTLV((int) 5));
			// }

			if (payLotteryInfo != null
					&& payLotteryInfo.getState() != MmochatPayLotteryState.活动结束) {
				tlv.addItemEvent(MmochatUtil.wrapColor("限时充值抽大奖活动", Color.red),
						new ClearDataTLV(), new AddDataTLV((int) 6));
			}

			if (fastPayLotteryInfo != null
					&& fastPayLotteryInfo.getState() == MmochatPayLotteryState.开始统计) {
				tlv.addItemEvent(MmochatUtil.wrapColor("即开型充值抽奖活动", Color.red),
						new ClearDataTLV(), new AddDataTLV((int) 9));
			}

			if (canTakeFirstPayAward(me)) {
				tlv.addItemEvent(MmochatUtil.wrapColor("首次充值超级豪礼", Color.red),
						new ClearDataTLV(), new AddDataTLV((int) 7));
			}

			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_13_14, (int) me
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 玩家系统: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("进入");
			tlv.setRightName("返回");
			tlv.setTitle("玩家系统");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());

			tlv.addItemEvent("玩家商会", new ClearDataTLV(),
					new AddDataTLV((int) 1));

			tlv.addItemEvent("元宝交易", new ClearDataTLV(),
					new AddDataTLV((int) 2));

			tlv.addItemEvent("在线奖励", new ClearDataTLV(),
					new AddDataTLV((int) 3));

			tlv.addItemEvent("出借找回", new ClearDataTLV(),
					new AddDataTLV((int) 4));

			tlv.addItemEvent("官方线下交易", new ClearDataTLV(), new AddDataTLV(
					(int) 5));

			if (MmochatConstant.isNewsOpen) {
				tlv.addItemEvent("新闻角", new ClearDataTLV(), new AddDataTLV(
						(int) 6));
			}

			if (MmochatConstant.isBattleRecordOpen) {
				tlv.addItemEvent("战斗录像", new ClearDataTLV(), new AddDataTLV(
						(int) 7));
			}

			if (MmochatConstant.isStoneBetOpen) {
				tlv.addItemEvent("石头剪刀布比赛", new ClearDataTLV(), new AddDataTLV(
						(int) 9));
			}

			tlv
					.addItemEvent("排行榜", new ClearDataTLV(), new AddDataTLV(
							(int) 8));

			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_13_28, (int) me
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 刷道比赛: {
			if (daoActivityInfo == null
					|| daoActivityInfo.getState() == MmochatPayLotteryState.活动结束) {
				return MmochatUtil.msgbox(req.getHallState(), "刷道比赛已结束或未开始!");
			}

			switch (daoActivityInfo.getState()) {
			case 开始统计: {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.List);
				tlv.setLeftName("查看");
				tlv.setRightName("返回");
				tlv.setTitle("刷道比赛");
				tlv.setWinHeight(208);
				tlv.addRightTLV(new CloseWinTLV());

				tlv.addItemEvent("活动介绍", new ClearDataTLV(), new AddDataTLV(
						(int) 1));
				tlv.addItemEvent("当前排名", new ClearDataTLV(), new AddDataTLV(
						(int) 2));
				tlv.addItemEvent("活动奖励", new ClearDataTLV(), new AddDataTLV(
						(int) 3));

				tlv.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_13_26, (int) me
								.getRoleId()));
				tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 停止统计: {
				// 当前排名
				List<MmochatDaoRole> top = daoActivityInfo.getTop();

				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.List);
				tlv.setRightName("返回");
				tlv.setTitle("获奖名单");
				tlv.setWinHeight(208);
				tlv.addRightTLV(new CloseWinTLV());

				int index = 1;
				for (MmochatDaoRole info : top) {
					String content = MmochatUtil.wrapColor("第" + index + "名:"
							+ info.getName() + "\n", Color.magenta);
					content += "ID:"
							+ Integer.toHexString((3 * info.getRoleId()))
							+ "\n";
					content += "累积:" + info.getDao() + "天\n";
					content += "奖励:"
							+ daoActivityInfo.getMoneyAwards().get(index - 1)
							+ daoActivityInfo.getMoneyType().toString();
					tlv.addItemEvent(content);
					index++;
				}
				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			default:
				break;
			}
			return MmochatUtil.msgbox(req.getHallState(), "刷道比赛已结束或未开始!");
		}
		default:
			return MmochatUtil.msgbox(req.getHallState(), "此功能暂不开放!");
		}
	}

	// 在线奖励tlv
	public CreateTlvWin getOnlineAwardTlv(MmochatPlayer me) {
		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.Text);
		tlv.setLeftName("领奖");
		tlv.setRightName("返回");
		tlv.setTitle("在线奖励");
		tlv.setWinHeight(208);
		tlv.setWinId(MmochatConstant.TLV_WIN_ONLINEAWARD);
		tlv.addRightTLV(new CloseWinTLV(MmochatConstant.TLV_WIN_ONLINEAWARD));
		String content = "";
		long onlineTime = System.currentTimeMillis()
				- me.getLastOnlineAwardTick();
		long awardNum = onlineTime / MmochatConstant.intervalOfOnlineAward;
		awardNum = Math.min(awardNum, MmochatConstant.maxTimeOfOnlineAward);
		content += MmochatUtil.wrapColor("奖励累积:" + awardNum + "份\n",
				Color.yellow);
		if (awardNum >= MmochatConstant.maxTimeOfOnlineAward) {
			content += MmochatUtil.wrapColor("最多累积"
					+ MmochatConstant.maxTimeOfOnlineAward + "份\n",
					Color.yellow);
		} else {
			long restTime = (awardNum + 1)
					* MmochatConstant.intervalOfOnlineAward - onlineTime;
			content += MmochatUtil.wrapColor("距离下个奖励:"
					+ (restTime / MmochatConstant.MS_PER_MINUTE) + "分\n",
					Color.yellow);
		}
		content += "\n";
		content += MmochatUtil.wrapColor("[在线奖励说明]\n", Color.green);
		content += "在游戏内每在线"
				+ (MmochatConstant.intervalOfOnlineAward / MmochatConstant.MS_PER_MINUTE)
				+ "分钟可获得一份奖励。" + MmochatUtil.wrapColor("下线奖励清空。", Color.red)
				+ "奖励可累积，最多累积" + MmochatConstant.maxTimeOfOnlineAward
				+ "份。奖励可能为经验、道行、战绩、金钱、元宝、道具。";
		tlv.setContent(new Text(content));

		tlv.addLeftTLV(new ClearDataTLV());
		tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_13_23, (int) me.getRoleId()));
		ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
		wait.setShowCancel(false);
		tlv.addLeftTLV(wait);
		return tlv;
	}

	// 13.23 领取在线奖励
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_23(SkymobiHandler handler,
			Mmochat_13_23C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		long onlineTime = System.currentTimeMillis()
				- me.getLastOnlineAwardTick();
		long awardNum = onlineTime / MmochatConstant.intervalOfOnlineAward;
		awardNum = Math.min(awardNum, MmochatConstant.maxTimeOfOnlineAward);
		if (awardNum == 0) {
			long restTime = (awardNum + 1)
					* MmochatConstant.intervalOfOnlineAward - onlineTime;
			return MmochatUtil
					.msgbox(req.getHallState(), "您还需在线"
							+ (restTime / MmochatConstant.MS_PER_MINUTE)
							+ "分钟就能领取奖励啦!");
		}
		// 50个本等级怪的经验，1年道行(经实际削减后最少60天) ，100点战绩，
		// 0.05%的机会获得1000个元宝，0.1%的机会获得喇叭1个

		String myInfo = "";
		for (int i = 0; i < awardNum; i++) {
			double randValue = Math.random() * 100; // [0,100)
			if (randValue < 0.05) {
				// 1000元宝
				me.addBig_money(1000);
				myInfo += MmochatUtil.wrapColor("您获得了1000元宝!", Color.red);

				String systemInfo = "恭喜"
						+ MmochatUtil.wrapColor(me.getName(), Color.green)
						+ "领取在线奖励时获得"
						+ MmochatUtil.wrapColor("1000元宝", Color.yellow)
						+ "!快按9键进入在线奖励免费领取吧。";
				MmochatChatService.sendSystemMsg(systemInfo);
			} else if (randValue < 0.05 + 0.1) {
				// 喇叭1个
				MmochatProp prop = new MmochatProp(MmochatPropType.喇叭);
				me.addObjectToPackage(prop);
				myInfo += "您获得了一个" + MmochatUtil.wrapColor("喇叭", Color.yellow)
						+ "!";
			} else if (randValue < 34) {
				// 50个本等级怪的经验
				int expAward = MmochatPetService.getMonsterExpByLevel(me, 50);
				me.addExp(expAward);
				myInfo += "您获得了" + expAward + "点经验!";
			} else if (randValue < 66) {
				// 1年道行(经实际削减后最少60天)
				// 刷道比赛
				MmochatPropService.dealDaoActivity(me, 365);

				int trueDao = MmochatBattleService.getRealDao(me, 365);
				if (trueDao < 60) {
					trueDao = 60;
				}
				me.addDao(trueDao);
				myInfo += "您获得了" + trueDao + "天道行!";
			} else {
				// 100点战绩
				me.addZhanji(100);
				myInfo += "您获得了100点战绩!";
			}
		}
		if (awardNum >= MmochatConstant.maxTimeOfOnlineAward) {
			me.setLastOnlineAwardTick(System.currentTimeMillis());
		} else {
			long newTick = me.getLastOnlineAwardTick() + awardNum
					* MmochatConstant.intervalOfOnlineAward;
			me.setLastOnlineAwardTick(newTick);
		}

		// 保存数据库
		try {
			MmochatDao.updateRoleOnlineAward(me);
		} catch (Exception e) {
			e.printStackTrace();
		}
		MmochatChatService.sendSystemMsgToPerson(me, myInfo);
		return MmochatUtil.msgbox(req.getHallState(), myInfo);
	}

	public CreateTlvWin getPayAwardTlv(MmochatPlayer me) {
		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.Text);
		tlv.setLeftName("抽奖");
		tlv.setRightName("返回");
		tlv.setTitle("充值抽奖");
		tlv.setWinHeight(208);
		tlv.setWinId(MmochatConstant.TLV_WIN_AWARD);
		tlv.addRightTLV(new CloseWinTLV(MmochatConstant.TLV_WIN_AWARD));
		String content = "";

		content += MmochatUtil.wrapColor("剩余抽奖次数:\n" + me.getRest_award_times()
				+ "次", Color.magenta);

		content += "\n\n" + MmochatUtil.wrapColor("奖品列表", Color.yellow) + "\n";
		content += MmochatUtil.wrapColor("高力玄武(神兽)", Color.red) + "、";
		content += MmochatUtil.wrapColor("通灵玄武(神兽)", Color.red) + "、";
		content += MmochatUtil.wrapColor("铁血玄武(神兽)", Color.red) + "、";
		content += MmochatUtil.wrapColor("幻影玄武(神兽)", Color.red) + "、";
		content += MmochatUtil.wrapColor("8级神行法宝", Color.cyan) + "、\n";
		content += "商城道具、首饰、套装材料、金钱、道行等\n\n";
		content += MmochatUtil.wrapColor("抽奖次数的获得", Color.yellow);
		content += "\n一次性兑换或充值" + MmochatConstant.payValuePerAward
				+ "元宝即可获得1次抽奖机会，" + "一次性兑换或充值"
				+ (2 * MmochatConstant.payValuePerAward) + "元宝可获得2次抽奖机会，依此类推。";
		tlv.setContent(new Text(content));

		tlv.addLeftTLV(new ClearDataTLV());
		tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_13_16, (int) me.getRoleId()));
		ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
		wait.setShowCancel(false);
		tlv.addLeftTLV(wait);
		return tlv;
	}

	// 13.14打开充值页面
	@SuppressWarnings("deprecation")
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_14(SkymobiHandler handler,
			Mmochat_13_14C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		switch (req.getIndex()) {
		case 1: {
			// K币兑换元宝
			if (!MmochatConstant.isKBPayOpen) {
				return MmochatUtil.msgbox(req.getHallState(), "K币兑换临时关闭!");
			}
			CreateTlvWin tlv = getPaymentPage(me);
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 2:// 充值卡兑换元宝,生成订单下发
			if (!MmochatConstant.isDirectPayOpen) {
				return MmochatUtil.msgbox(req.getHallState(), "充值卡兑换功能临时关闭!");
			}
			// 组队下不下发
			if (MmochatTeamService.getTeamState(me) == MmochatTeamStateType.队员) {
				return MmochatUtil.msgbox(req.getHallState(),
						"在队伍中不能打开充值卡充值界面!");
			}
			ChargeOrderService.sendNewOrder(me);
			return null;
		case 3: {
			// 本期充值抽奖活动
			CreateTlvWin tlv = getPayAwardTlv(me);
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 4: {
			// 每月首次充值豪礼
			if (!MmochatConstant.isFirstPayThisMonthActivityOpen) {
				return MmochatUtil.msgbox(req.getHallState(),
						"此活动暂时关闭，请关注官方公告!");
			}
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle("每月首次充值");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());
			String content = MmochatUtil.wrapColor("[活动介绍]\n", Color.yellow);
			content += "每月首次使用"
					+ MmochatUtil.wrapColor("充值卡", Color.yellow)
					+ "充值就可获得当月期间的"
					+ MmochatUtil.wrapColor("所有属性+"
							+ MmochatConstant.attrValueForFirstPayThisMonth,
							Color.red)
					+ "、"
					+ MmochatUtil.wrapColor("所有天赋+"
							+ MmochatConstant.giftValueForFirstPayThisMonth,
							Color.red) + "的效果。K币充值不参与本活动。\n\n";

			content += MmochatUtil.wrapColor("[有效充值]\n", Color.yellow);
			content += "通过<充值卡充值元宝>才可以参加本活动。\n\n";

			content += MmochatUtil.wrapColor("[其它说明]\n", Color.yellow);
			content += "1、充值不限额度，充值1元宝也可以参加此活动。\n";
			content += "2、属性加成效果从充值时起，到当月月底。"
					+ "下月1号0时效果消失，下月再次充值，即可再次激活一个月的有效期。\n";
			content += "3、积分兑换元宝，或通过元宝交易购买元宝，或K币充值都不能参加此活动。"
					+ "只有通过充值卡充值元宝，才能参加此活动。\n";
			content += "4、本活动解释权归仙剑问情官方所有。官方有权根据情况随时中止本活动，请大家见谅!";

			tlv.setContent(new Text(content));
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 5: {
			// 充值排行送神兽
			Date now = new Date();
			if (now.getMonth() == 1 && now.getDate() >= 4 && now.getDate() <= 6) {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.Text);
				tlv.setLeftName("抽奖");
				tlv.setRightName("返回");
				tlv.setTitle("充值排行送神兽");
				tlv.setWinHeight(208);
				tlv.addRightTLV(new CloseWinTLV());

				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				msgbox.setContent(new Text("充值前10名的玩家可以在"
						+ MmochatUtil.wrapColor("2月7号", Color.red)
						+ "在此界面进行抽奖，过期作废。现在不是抽奖时间。"));
				msgbox.setLeftName("确定");
				tlv.addLeftTLV(msgbox);

				String content = "";
				content += MmochatUtil.wrapColor("充值排行送神兽\n", Color.yellow);
				content += "1、活动介绍\n";
				content += "2、抽奖说明\n";
				content += "3、"
						+ MmochatUtil.wrapColor("当前充值前十名", Color.magenta)
						+ "\n\n";

				content += MmochatUtil.wrapColor("详细信息\n", Color.yellow);
				content += MmochatUtil.wrapColor("1、活动介绍\n", Color.green);
				content += "2月4号至6号，累计充值(K币兑换或充值卡充值)最高的必然获得一个"
						+ MmochatUtil.wrapColor("玄武(神兽)", Color.red)
						+ ",第2名至第10名还有多次抽奖机会。充值排行整点进行更新，"
						+ "以2月7号0点0分排行为准。\n\n";

				content += MmochatUtil.wrapColor("2、抽奖说明\n", Color.green);
				content += "第1名有1次抽奖机会且必然抽中神兽；"
						+ "第2~4名有3次抽奖机会；第5~7名有2次抽奖机会；第8~10名有1次抽奖机会。";
				content += "大奖设置有："
						+ MmochatUtil.wrapColor("玄武(神兽)", Color.red) + "、"
						+ MmochatUtil.wrapColor("小龙人(变异)", Color.red) + "、"
						+ MmochatUtil.wrapColor("8级神行法宝", Color.yellow)
						+ "，每次抽奖有"
						+ MmochatUtil.wrapColor("17%机率", Color.magenta)
						+ "获得大奖。"
						+ MmochatUtil.wrapColor("抽奖仅限2月7号一天", Color.red)
						+ "，过期作废。\n\n";

				content += MmochatUtil.wrapColor("3、当前充值前十名\n", Color.green);
				if (MmochatTempActivityService.payRank.size() == 0) {
					content += MmochatUtil.wrapColor("暂无人上榜!", Color.magenta);
				} else {
					// 判断我是否在榜上
					int index = 1;
					int startShowIndex = MmochatTempActivityService.payRank
							.size(); // 如果不在榜上，则只显示最后一名的充值额
					for (MmochatRolePayInfo info : MmochatTempActivityService.payRank) {
						if (info.getRoleId() == me.getRoleId()) {
							startShowIndex = index - 1;
							break;
						}
						index++;
					}

					index = 1;
					for (MmochatRolePayInfo info : MmochatTempActivityService.payRank) {
						content += MmochatUtil.wrapColor("第" + index + "名:"
								+ info.getName(), Color.magenta);
						if (index >= startShowIndex) {
							// 显示充值额
							content += "\n第"
									+ index
									+ "名充值"
									+ MmochatUtil.wrapColor(
											info.getTotal_pay() / 100,
											Color.yellow) + "元";
						}
						content += "\n";
						index++;
					}
				}
				tlv.setContent(new Text(content));

				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			} else if (now.getMonth() == 1 && now.getDate() == 7) {
				if (now.getHours() == 0 && now.getMinutes() < 10) {
					// 冻结期
					return MmochatUtil.msgbox(req.getHallState(),
							"0点10分公布本次充值排行活动名次，届时开启抽奖活动，请稍等片刻!");
				}

				// 开奖了
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.Text);
				tlv.setLeftName("抽奖");
				tlv.setRightName("返回");
				tlv.setTitle("充值排行送神兽");
				tlv.setWinHeight(208);
				tlv.addRightTLV(new CloseWinTLV());

				// 判断我是否在榜上
				MmochatRolePayInfo myInfo = null;
				int index = 1;
				for (MmochatRolePayInfo info : MmochatTempActivityService.payRank) {
					if (info.getRoleId() == me.getRoleId()) {
						myInfo = info;
						break;
					}
					index++;
				}

				if (myInfo == null) {
					CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
					msgbox.setContent(new Text("您没有上榜，无法进行抽奖!"));
					msgbox.setLeftName("确定");
					tlv.addLeftTLV(msgbox);
				} else {
					// 进行抽奖
					tlv.addLeftTLV(new ClearDataTLV());
					tlv.addLeftTLV(new SendDataTLV(MmochatConstant
							.getClientModuleId(),
							MmochatMain.getModuleInstID(),
							MmochatConstant.MSGCODE_MMOCHAT_C_13_21, (int) me
									.getRoleId()));
					ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
					wait.setShowCancel(false);
					tlv.addLeftTLV(wait);
				}

				String content = "";
				if (myInfo != null) {
					content += MmochatUtil.wrapColor("您在本次活动中获得了第" + index
							+ "名，当前您还有" + myInfo.getAwardTimes() + "次抽奖机会。",
							Color.yellow);
					if (index == 1) {
						content += MmochatUtil.wrapColor(
								"\n由于您获得了第1名，本次抽奖必然会获得一只神兽。", Color.green);
					}
					content += MmochatUtil.wrapColor("\n请在2月7号当天进行抽奖，过期作废。",
							Color.red);
					content += "\n";
				}

				content += MmochatUtil.wrapColor("[奖项设置]\n", Color.green);
				content += MmochatUtil.wrapColor("玄武(神兽)", Color.red) + "、\n"
						+ MmochatUtil.wrapColor("小龙人(变异)", Color.red) + "、\n"
						+ MmochatUtil.wrapColor("8级神行法宝", Color.yellow) + "、\n"
						+ "道行、战绩、道具奖励。\n";
				content += MmochatUtil.wrapColor(
						"每次抽奖，神兽、变异、8级神行法宝中奖率为17%!\n\n", Color.magenta);

				content += MmochatUtil.wrapColor("[充值排名]\n", Color.green);
				if (MmochatTempActivityService.payRank.size() == 0) {
					content += MmochatUtil.wrapColor("暂无人上榜!", Color.magenta);
				} else {
					index = 1;
					for (MmochatRolePayInfo info : MmochatTempActivityService.payRank) {
						content += MmochatUtil.wrapColor("第" + index + "名:"
								+ info.getName(), Color.magenta);
						content += "\n";
						index++;
					}
				}
				tlv.setContent(new Text(content));

				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			} else {
				return MmochatUtil.msgbox(req.getHallState(), "此活动未开放!");
			}
		}
		case 6: {
			// 限时充值抽大奖活动
			if (payLotteryInfo != null
					&& payLotteryInfo.getState() != MmochatPayLotteryState.活动结束) {
				switch (payLotteryInfo.getState()) {
				case 开始统计: {
					CreateTlvWin tlv = new CreateTlvWin();
					tlv.setWinType(WinType.Text);
					tlv.setRightName("返回");
					tlv.setTitle("限时充值抽大奖");
					tlv.setWinHeight(208);
					tlv.addRightTLV(new CloseWinTLV());

					String content = "";
					MmochatLotteryRole myInfo = payLotteryInfo.getPayRoles()
							.get(me.getRoleId());
					if (myInfo != null) {
						if (myInfo.getMoney() < payLotteryInfo.getMoneyNeed()) {
							content += MmochatUtil.wrapColor("您只要再充值"
									+ (payLotteryInfo.getMoneyNeed() - myInfo
											.getMoney()) / 100 + "元即可参加抽奖\n",
									Color.magenta);
						} else {
							content += MmochatUtil.wrapColor(
									"您有中奖资格,活动时间结束时抽奖\n", Color.magenta);
						}
					}
					content += MmochatUtil.wrapColor("[活动时间]\n", Color.green);
					content += payLotteryInfo.getTimeInfo() + "\n";
					content += MmochatUtil.wrapColor("[活动奖励]\n", Color.green);
					content += "从参与者中抽"
							+ MmochatUtil.wrapColor(payLotteryInfo
									.getLotteryNum()
									+ "名", Color.yellow)
							+ "，每人获得"
							+ MmochatUtil.wrapColor(payLotteryInfo
									.getMoneyAward()
									+ payLotteryInfo.getMoneyType().toString(),
									Color.yellow) + "\n";
					content += MmochatUtil.wrapColor("[充值要求]\n", Color.green);
					content += "活动时间内累积充值满" + payLotteryInfo.getMoneyNeed()
							/ 100 + "元\n";
					content += MmochatUtil.wrapColor("[当前参与人数]\n", Color.green);
					content += MmochatUtil.wrapColor(payLotteryInfo
							.calLotteryRoleNum()
							+ "人\n", Color.yellow);
					content += MmochatUtil.wrapColor("[活动介绍]\n", Color.green);
					content += "在<活动时间>内，累积充值满" + payLotteryInfo.getMoneyNeed()
							/ 100 + "元(或" + payLotteryInfo.getMoneyNeed()
							+ "K币)，即可参加抽奖。抽奖在活动时间结束时进行，"
							+ "由系统随机从参与者中抽机若干名。如果奖励为K币奖励，"
							+ "则将在7个工作日内统一发放，如果为元宝、金钱奖励则会即时发放。";

					tlv.setContent(new Text(content));
					return MmochatUtil.tlvResponse(req.getHallState(), tlv);
				}
				case 停止统计: {
					CreateTlvWin tlv = new CreateTlvWin();
					tlv.setWinType(WinType.Text);
					tlv.setRightName("返回");
					tlv.setTitle("限时充值抽大奖");
					tlv.setWinHeight(208);
					tlv.addRightTLV(new CloseWinTLV());

					String content = "";
					MmochatLotteryRole myInfo = payLotteryInfo.getPayRoles()
							.get(me.getRoleId());
					if (myInfo != null) {
						if (myInfo.isHit()) {
							content += MmochatUtil.wrapColor(
									"恭喜!您被系统抽中，获得大奖!\n", Color.red);
						}
					}
					content += MmochatUtil.wrapColor("[活动时间]\n", Color.green);
					content += "本轮活动已结束\n";
					content += MmochatUtil.wrapColor("[活动奖励]\n", Color.green);
					content += "从参与者中抽"
							+ MmochatUtil.wrapColor(payLotteryInfo
									.getLotteryNum()
									+ "名", Color.yellow)
							+ "，每人获得"
							+ MmochatUtil.wrapColor(payLotteryInfo
									.getMoneyAward()
									+ payLotteryInfo.getMoneyType().toString(),
									Color.yellow) + "\n";
					content += MmochatUtil.wrapColor("[参与人数]\n", Color.green);
					content += MmochatUtil.wrapColor(payLotteryInfo
							.calLotteryRoleNum()
							+ "人\n", Color.yellow);
					content += MmochatUtil.wrapColor("[获奖名单]\n", Color.green);
					for (MmochatLotteryRole role : payLotteryInfo.getHitRoles()) {
						content += role.getName() + "(ID:"
								+ Integer.toHexString(role.getRoleId() * 3)
								+ ")\n";
					}

					content += MmochatUtil.wrapColor("[活动介绍]\n", Color.green);
					content += "在<活动时间>内，累积充值满" + payLotteryInfo.getMoneyNeed()
							/ 100 + "元(或" + payLotteryInfo.getMoneyNeed()
							+ "K币)，即可参加抽奖。抽奖在活动时间结束时进行，"
							+ "由系统随机从参与者中抽机若干名。如果奖励为K币奖励，"
							+ "则将在7个工作日内统一发放，如果为元宝、金钱奖励则会即时发放。";

					tlv.setContent(new Text(content));
					return MmochatUtil.tlvResponse(req.getHallState(), tlv);
				}
				default:
					break;
				}
			}
			break;
		}
		case 7: {
			if (!MmochatSystemState.isFirstPay_open()) {
				return MmochatUtil.msgbox(req.getHallState(), "此活动已经结束!");
			}

			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle("首次充值超级豪礼");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());

			String content = "";
			content += MmochatUtil.wrapColor("[活动奖励]\n", Color.yellow);
			content += MmochatUtil.wrapColor(MmochatSystemState
					.getFirstPay_daoAward()
					+ "年道行\n"
					+ MmochatSystemState.getFirstPay_expAward()
					+ "次同等级怪物经验\n\n", Color.red);
			content += MmochatUtil.wrapColor("[参加条件]\n", Color.yellow);
			content += "从未充值过的角色，且等级不低于"
					+ MmochatSystemState.getFirstPay_minLevel() + "级\n\n";
			content += MmochatUtil.wrapColor("[奖励说明]\n", Color.yellow);
			content += "满足条件的用户，在活动期间进行K币或充值卡充值，充值完成时立即获得上述大奖!"
					+ "其中道行奖励与所有道行奖励相同，都受标准道行削减影响，"
					+ "即如果人物道行高于标准道行越多，则奖励削减越多。标准道行=等级X等级X等级X0.29(天)\n\n";
			content += MmochatUtil.wrapColor("[活动时间]\n", Color.yellow);
			content += "新区开区几个月内不会开启此活动，活动时间通过游戏内公告发布，敬请关注。";
			tlv.setContent(new Text(content));
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 8: {
			// 邮政储蓄汇款
			if (!MmochatConstant.isOwnBankPayOpen
					|| MmochatNpcService.famousList.get(me.getRoleId()) == null) {
				return MmochatUtil.msgbox(req.getHallState(), "此活动未开始!");
			}

			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle("邮政储蓄兑换元宝");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());

			String content = "";
			content += "为方便部分无法购到充值卡及未办理过银行卡的用户，现开通邮政储蓄银行汇款充值，活动期间1元可兑换"
					+ MmochatConstant.bankPayChangeRate + "元宝!\n\n";
			content += MmochatUtil.wrapColor("[汇款流程]\n", Color.yellow);
			content += MmochatUtil.wrapColor(
					"第一步：记下您的角色ID，拨打0571-85222407客服电话，或联系客服QQ:1969126016，"
							+ "告之角色ID及汇款金额，", Color.green)
					+ MmochatUtil.wrapColor("未联系上客服请不要汇款，以免元宝无法到账\n\n",
							Color.red);
			content += MmochatUtil.wrapColor("第二步：到中国邮政储蓄银行，给以下账户进行汇款：\n",
					Color.green);
			content += MmochatUtil.wrapColor(
					"中国邮政储蓄银行\n收款人:陈玉林\n卡号:6221503310013199287\n\n",
					Color.magenta);
			content += MmochatUtil.wrapColor(
					"第三步：请打0571-85222407客服电话，或联系汇款客服QQ:1969126016，"
							+ "通知客服完成汇款，客服核实后发放元宝。\n\n", Color.green);
			content += MmochatUtil.wrapColor("[其它说明]\n", Color.yellow);
			content += "目前只接受荣登排行榜的用户汇款兑换元宝。\n"
					+ "客服接待时间:周一至周五，10:00-18:00，请在此期间联系客服。";
			tlv.setContent(new Text(content));
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);

		}
		case 9: {
			// 即开型充值抽奖
			CreateTlvWin tlv = getFastLotteryTlv(me);
			if (tlv == null) {
				return MmochatUtil.msgbox(req.getHallState(), "此活动尚未开始或已结束");
			}
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 10: {
			// 充值卡预充值活动
			if (!MmochatGmService.isTodayDelayPayOpen()) {
				return MmochatUtil.msgbox(req.getHallState(), "此活动尚未开始或已结束");
			}
			MmochatGmService.delayPayEffectShowTimes++;
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("进入");
			tlv.setRightName("返回");
			tlv.setTitle("预充值活动");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());

			String msg = "预充值的元宝不是即时到账，"
					+ MmochatUtil.wrapColor("一般1至12小时内到账", Color.yellow) + "，"
					+ "充值前请阅读<预充值活动说明>。\n您确定要预充值么?";
			CreateMsgBoxTLV msgbox1 = new CreateMsgBoxTLV();
			msgbox1.setContent(new Text(msg));
			msgbox1.setLeftName("确定");
			msgbox1.setRightName("取消");
			msgbox1.addLeftTLV(new ClearDataTLV());
			msgbox1.addLeftTLV(new AddDataTLV((int) 2));
			msgbox1.addLeftTLV(new SendDataTLV(MmochatConstant
					.getClientModuleId(), MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_20_19, (int) me
							.getRoleId()));
			msgbox1.addLeftTLV(new ShowWaitingMsgBoxTLV());

			CreateMsgBoxTLV msgbox2 = new CreateMsgBoxTLV();
			msgbox2.setContent(new Text(msg));
			msgbox2.setLeftName("确定");
			msgbox2.setRightName("取消");
			msgbox2.addLeftTLV(new ClearDataTLV());
			msgbox2.addLeftTLV(new AddDataTLV((int) 3));
			msgbox2.addLeftTLV(new SendDataTLV(MmochatConstant
					.getClientModuleId(), MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_20_19, (int) me
							.getRoleId()));
			msgbox2.addLeftTLV(new ShowWaitingMsgBoxTLV());

			tlv.addItemEvent("预充值活动说明", new ClearDataTLV(), new AddDataTLV(
					(int) 1), new SendDataTLV(MmochatConstant
					.getClientModuleId(), MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_20_19, (int) me
							.getRoleId()), new ShowWaitingMsgBoxTLV());
			tlv.addItemEvent("预充"
					+ MmochatUtil.wrapColor("移动充值卡", Color.yellow), msgbox1);
			tlv.addItemEvent("预充"
					+ MmochatUtil.wrapColor("联通充值卡", Color.yellow), msgbox2);
			tlv.addItemEvent("我的充值订单", new ClearDataTLV(), new AddDataTLV(
					(int) 4), new SendDataTLV(MmochatConstant
					.getClientModuleId(), MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_20_19, (int) me
							.getRoleId()), new ShowWaitingMsgBoxTLV());

			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 11: {
			// 我的充值订单
			List<MmochatDelayPay> myOrders = new ArrayList<MmochatDelayPay>();
			for (MmochatDelayPay pay : MmochatGmService.delayPays.values()) {
				if (pay.getRoleId() == me.getRoleId()) {
					if (pay.getState() != MmochatDelayPayState.创建中) {
						myOrders.add(pay);
					}
				}
			}
			if (myOrders.size() == 0) {
				return MmochatUtil.msgbox(req.getHallState(), "您还没有进行过预充值!");
			}
			Collections.sort(myOrders);

			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setRightName("返回");
			tlv.setLeftName("详情");
			tlv.setTitle("我的预充值订单");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());
			int index = 1;
			for (MmochatDelayPay pay : myOrders) {
				String item = index + "、";
				if (pay.getState() == MmochatDelayPayState.充值成功) {
					item += MmochatUtil.wrapColor("["
							+ pay.getState().toString() + "]" + pay.getMoney()
							+ "元" + pay.getType().toString(), Color.yellow);
				} else if (pay.getState() == MmochatDelayPayState.充值失败) {
					item += MmochatUtil.wrapColor("["
							+ pay.getState().toString() + "]" + pay.getMoney()
							+ "元" + pay.getType().toString(), Color.red);
				} else {
					item += "[" + pay.getState().toString() + "]"
							+ pay.getMoney() + "元" + pay.getType().toString();
				}
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) pay.getId()));
			}
			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_20_25, (int) me
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		default:
			break;
		}
		return null;
	}

	// 获取即开型抽奖页面
	public static CreateTlvWin getFastLotteryTlv(MmochatPlayer me) {
		// 即开型充值抽奖
		if (fastPayLotteryInfo == null
				|| fastPayLotteryInfo.getState() != MmochatPayLotteryState.开始统计) {
			return null;
		}

		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.Text);
		tlv.setLeftName("抽奖");
		tlv.setRightName("返回");
		tlv.setTitle("即开型充值抽奖");
		tlv.setWinHeight(208);
		tlv.setWinId(MmochatConstant.TLV_WIN_FASTLOTTERY);
		tlv.addRightTLV(new CloseWinTLV(MmochatConstant.TLV_WIN_FASTLOTTERY));
		String content = "";
		content += MmochatUtil.wrapColor("您有"
				+ fastPayLotteryInfo.getRoleAwardTimes(me.getRoleId())
				+ "次抽奖机会\n\n", Color.magenta);
		content += MmochatUtil.wrapColor("[活动说明]\n", Color.yellow);
		content += "一次性充值满" + (fastPayLotteryInfo.getMoneyNeed() / 100)
				+ "元得1次抽奖机会，满" + (2 * fastPayLotteryInfo.getMoneyNeed() / 100)
				+ "元得2次机会，依次类推。";
		content += "奖品从奖池中抽取，100%中奖!\n";

		content += MmochatUtil.wrapColor("[奖池]\n", Color.yellow);
		for (MmochatFastLotteryAwardTitle title : fastPayLotteryInfo
				.getAwardTitle()) {
			content += MmochatUtil.wrapColor(title.getMoneyAward()
					+ title.getMoneyType().toString() + ":", Color.magenta);
			content += "剩" + (title.getTotalNum() - title.getCostNum()) + "份,共"
					+ title.getTotalNum() + "份\n";
		}
		content += "\n";
		content += MmochatUtil.wrapColor("[幸运中奖信息]\n", Color.yellow);

		Object[] infoList = fastPayLotteryInfo.getLatestAwardInfo();
		String tmp = "";
		for (Object o : infoList) {
			String str = (String) o;
			if (str.length() > 0) {
				tmp = str + "\n" + tmp;
			}
		}
		content += tmp;
		tlv.setContent(new Text(content));

		tlv.addLeftTLV(new ClearDataTLV());
		tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_13_27, (int) me.getRoleId()));
		ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
		wait.setShowCancel(false);
		tlv.addLeftTLV(wait);
		return tlv;
	}

	// 13.5 使用元宝购买物品
	@SuppressWarnings("unchecked")
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_5(SkymobiHandler handler,
			Mmochat_13_5C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (MmochatConstant.shopClassVersion != req.getVersion()) {
			return MmochatUtil.msgbox(req.getHallState(), "您的版本过旧,请退出游戏重新进入!");
		}

		int num = req.getNum();
		if (num < 1) {
			return MmochatUtil.msgbox(req.getHallState(), "购买的数量必须大于0!");
		}
		if (num > 99) {
			return MmochatUtil.msgbox(req.getHallState(), "购买的数量最大为99!");
		}
		MmochatObjectType objType = MmochatObjectType
				.get(req.getObjTypeValue());
		MmochatCommonObjectType type = null;
		boolean canOverlap = false;
		int price = 0;
		String objName;
		MmochatCommonObject newObj;
		MmochatPropType propType = null;
		switch (objType) {
		case 道具:
			propType = MmochatPropType.get(req.getObjKey());
			canOverlap = propType.isCanOverLap();
			price = propType.getPrice() * num;
			objName = propType.toString();
			newObj = new MmochatProp(propType);
			if (canOverlap) {
				newObj.setOverlapNum(num);
			}
			type = propType;
			break;
		case 药品:
			MmochatDrugType drugType = MmochatDrugType.get(req.getObjKey());
			canOverlap = true;
			price = drugType.getPrice() * num;
			objName = drugType.toString();
			newObj = new MmochatDrug();
			if (canOverlap) {
				newObj.setOverlapNum(num);
			}
			type = drugType;
			break;
		case 装备:
			MmochatEquipType equipType = MmochatEquipType.get(req.getObjKey());
			int equipLevel = req.getEquipLevel();
			price = MmochatEquipService.getEquipPrice(equipType, equipLevel)
					* num;
			canOverlap = false;
			objName = MmochatEquipService.getEquipName(equipType, equipLevel);
			newObj = MmochatEquipService.createRandomEquip(true, equipType,
					equipLevel, MmochatEquipQualityType.白装);
			if (canOverlap) {
				newObj.setOverlapNum(num);
			}
			type = equipType;
			break;
		default:
			return MmochatUtil.msgbox(req.getHallState(), "此类物品暂不出售!");
		}

		if (newObj == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		// 保存购买前信息

		// 购买
		Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
				.deepClone(me.getMyPackage(),
						new TypeToken<Map<Integer, MmochatPackageGrid>>() {
						}.getType());

		List<MmochatPackageGrid> gridsNeedUpdate = new ArrayList<MmochatPackageGrid>();
		synchronized (me) {
			if (me.getBig_money() < price) {
				return MmochatUtil.msgbox(req.getHallState(), "您的元宝不足,购买"
						+ MmochatUtil.wrapColor(num, Color.yellow) + "个"
						+ objName + "需要"
						+ MmochatUtil.wrapColor(price, Color.yellow)
						+ "元宝!请选充值元宝。");
			}
			if (me.calRestPackageSpace(type, canOverlap, true) < num) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您的包裹空间不足!请先清理出空间再购买!");
			}
			if (canOverlap || num == 1) {
				gridsNeedUpdate.addAll(me.addObjectToPackage(newObj, false));
			} else {
				for (int i = 0; i < num; i++) {
					MmochatCommonObject obj = newObj.getCloneWithNewId();
					gridsNeedUpdate.addAll(me.addObjectToPackage(obj, false));
				}
			}
			me.addBig_money(-1 * price);
		}

		boolean exception_happened = false;
		long oldLimit = me.getLimit_bigmoney();
		me.addLimit_bigmoney(-1 * price);
		try {
			MmochatDao.buyBigMoneyObj(me, price);
		} catch (Exception e) {
			e.printStackTrace();
			exception_happened = true;
			me.setMyPackage(packageBak);
			me.addBig_money(price);
			me.setLimit_bigmoney(oldLimit);
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙，请稍候再试!");
		}
		MmochatStatisticsService.todayBigMoneyCost += price;

		Mmochat_13_5S pack = new Mmochat_13_5S();
		pack.setBigMoney((int) me.getBig_money());
		if (!exception_happened) {
			pack.setMsg("购买成功!请按3键打开包裹查看!");
			Mmochat_5_1S updatePack = new Mmochat_5_1S();
			updatePack.addGrid(gridsNeedUpdate);
			MmochatUtil.sendCommonPack(me, updatePack);
		} else {
			pack.setMsg("服务器忙,请稍候购买!");
		}
		MmochatUtil.sendCommonPack(me, pack);

		if (objType == MmochatObjectType.道具) {
			MmochatBigMoneyCostType earnType = MmochatBigMoneyCostType
					.valueOf(propType.toString());
			if (earnType != null) {
				MmochatStatisticsService.addBigMoneyCost(earnType, -1 * price);
			}
		}
		return null;
	}

	// 13.10 使用金钱购买物品
	@SuppressWarnings("unchecked")
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_10(SkymobiHandler handler,
			Mmochat_13_10C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (MmochatConstant.shopClassVersion != req.getVersion()) {
			return MmochatUtil.msgbox(req.getHallState(), "您的版本过旧,请退出游戏重新进入!");
		}

		int num = req.getNum();
		if (num < 1) {
			return MmochatUtil.msgbox(req.getHallState(), "购买的数量必须大于0!");
		}
		if (num > 99) {
			return MmochatUtil.msgbox(req.getHallState(), "购买的数量最大99!");
		}
		MmochatObjectType objType = MmochatObjectType
				.get(req.getObjTypeValue());
		MmochatCommonObjectType type = null;
		boolean canOverlap = false;
		int price = 0;
		String objName;
		MmochatCommonObject newObj;
		switch (objType) {
		case 道具:
			MmochatPropType propType = MmochatPropType.get(req.getObjKey());
			canOverlap = propType.isCanOverLap();
			price = propType.getPrice() * num;
			objName = propType.toString();
			newObj = new MmochatProp(propType);
			if (canOverlap) {
				newObj.setOverlapNum(num);
			}
			type = propType;
			break;
		case 药品:
			MmochatDrugType drugType = MmochatDrugType.get(req.getObjKey());
			canOverlap = true;
			price = drugType.getPrice() * num;
			objName = drugType.toString();
			newObj = new MmochatDrug();
			newObj.setDrugType(drugType);
			if (canOverlap) {
				newObj.setOverlapNum(num);
			}
			type = drugType;
			break;
		case 装备:
			MmochatEquipType equipType = MmochatEquipType.get(req.getObjKey());
			int equipLevel = req.getEquipLevel();
			price = MmochatEquipService.getEquipPrice(equipType, equipLevel)
					* num;
			canOverlap = false;
			objName = MmochatEquipService.getEquipName(equipType, equipLevel);
			newObj = MmochatEquipService.createRandomEquip(true, equipType,
					equipLevel, MmochatEquipQualityType.白装);
			if (canOverlap) {
				newObj.setOverlapNum(num);
			}
			type = equipType;
			break;
		default:
			return MmochatUtil.msgbox(req.getHallState(), "此类物品暂不出售!");
		}
		if (newObj == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		// 购买
		Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
				.deepClone(me.getMyPackage(),
						new TypeToken<Map<Integer, MmochatPackageGrid>>() {
						}.getType());

		List<MmochatPackageGrid> gridsNeedUpdate = new ArrayList<MmochatPackageGrid>();
		synchronized (me) {
			if (me.getSmall_money() < price) {
				return MmochatUtil.msgbox(req.getHallState(), "您的金钱不足,购买"
						+ MmochatUtil.wrapColor(num, Color.yellow) + "个"
						+ objName + "需要"
						+ MmochatUtil.wrapColor(price, Color.yellow) + "文钱!");
			}
			if (me.calRestPackageSpace(type, canOverlap, true) < num) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您的包裹空间不足!请先清理出空间再购买!");
			}
			if (canOverlap || num == 1) {
				gridsNeedUpdate.addAll(me.addObjectToPackage(newObj, false));
			} else {
				for (int i = 0; i < num; i++) {
					MmochatCommonObject obj = newObj.getCloneWithNewId();
					gridsNeedUpdate.addAll(me.addObjectToPackage(obj, false));
				}
			}
			me.addAndUpdateSmall_money(-1 * price);
		}
		Mmochat_13_5S pack = new Mmochat_13_5S();
		try {
			MmochatDao.buySmallMoneyObj(me, price);
			pack.setMsg("购买成功!请按3键打开包裹查看!");
			try {
				Mmochat_5_1S updatePack = new Mmochat_5_1S();
				updatePack.addGrid(gridsNeedUpdate);
				MmochatUtil.sendCommonPack(me, updatePack);
			} catch (Exception e) {
				e.printStackTrace();
			}
		} catch (Exception e) {
			e.printStackTrace();
			me.setMyPackage(packageBak);
			me.addAndUpdateSmall_money(price);
			pack.setMsg("服务器忙,请稍候购买!");
		}
		switch (objType) {
		case 道具:
			MmochatStatisticsService.addSmallMoneyCost(
					MmochatSmallMoneyCostType.购买杂货店物品, -1 * price);
			break;
		case 药品:
			MmochatStatisticsService.addSmallMoneyCost(
					MmochatSmallMoneyCostType.购买药店物品, -1 * price);
			break;
		case 装备:
			MmochatStatisticsService.addSmallMoneyCost(
					MmochatSmallMoneyCostType.购买武器防具店物品, -1 * price);
			break;
		default:
			break;
		}

		pack.setBigMoney((int) me.getSmall_money());
		MmochatUtil.sendCommonPack(me, pack);

		return null;
	}

	// 13.17 使用奖券兑换道具
	@SuppressWarnings("unchecked")
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_17(SkymobiHandler handler,
			Mmochat_13_17C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (MmochatConstant.shopClassVersion != req.getVersion()) {
			return MmochatUtil.msgbox(req.getHallState(), "您的版本过旧,请退出游戏重新进入!");
		}

		int num = req.getNum();
		if (num < 1) {
			return MmochatUtil.msgbox(req.getHallState(), "兑换的数量必须大于0!");
		}
		if (num > 99) {
			return MmochatUtil.msgbox(req.getHallState(), "兑换的数量最大99!");
		}
		MmochatObjectType objType = MmochatObjectType
				.get(req.getObjTypeValue());
		MmochatCommonObjectType type = null;
		boolean canOverlap = false;
		int price = 0;
		String objName;
		MmochatCommonObject newObj;
		switch (objType) {
		case 道具:
			MmochatPropType propType = MmochatPropType.get(req.getObjKey());
			canOverlap = propType.isCanOverLap();
			price = propType.getLottery() * num;
			objName = propType.toString();
			newObj = new MmochatProp(propType);
			if (canOverlap) {
				newObj.setOverlapNum(num);
			}
			type = propType;
			break;
		case 药品:
			MmochatDrugType drugType = MmochatDrugType.get(req.getObjKey());
			canOverlap = true;
			price = drugType.getPrice() * num;
			objName = drugType.toString();
			newObj = new MmochatDrug();
			newObj.setDrugType(drugType);
			if (canOverlap) {
				newObj.setOverlapNum(num);
			}
			type = drugType;
			break;
		case 装备:
			MmochatEquipType equipType = MmochatEquipType.get(req.getObjKey());
			int equipLevel = req.getEquipLevel();
			price = MmochatEquipService.getEquipPrice(equipType, equipLevel)
					* num;
			canOverlap = false;
			objName = MmochatEquipService.getEquipName(equipType, equipLevel);
			newObj = MmochatEquipService.createRandomEquip(true, equipType,
					equipLevel, MmochatEquipQualityType.白装);
			if (canOverlap) {
				newObj.setOverlapNum(num);
			}
			type = equipType;
			break;
		default:
			return MmochatUtil.msgbox(req.getHallState(), "此类物品暂不兑换!");
		}
		if (newObj == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		// 购买
		Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
				.deepClone(me.getMyPackage(),
						new TypeToken<Map<Integer, MmochatPackageGrid>>() {
						}.getType());

		List<MmochatPackageGrid> gridsNeedUpdate = new ArrayList<MmochatPackageGrid>();
		synchronized (me) {
			if (me.getLottery() < price) {
				return MmochatUtil.msgbox(req.getHallState(), "您的奖券不足,兑换"
						+ MmochatUtil.wrapColor(num, Color.yellow) + "个"
						+ objName + "需要"
						+ MmochatUtil.wrapColor(price, Color.yellow) + "张奖券!");
			}
			if (me.calRestPackageSpace(type, canOverlap, true) < num) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您的包裹空间不足!请先清理出空间再购买!");
			}
			if (canOverlap || num == 1) {
				newObj.setCanDeal(false);
				gridsNeedUpdate.addAll(me.addObjectToPackage(newObj, false));
			} else {
				for (int i = 0; i < num; i++) {
					MmochatCommonObject obj = newObj.getCloneWithNewId();
					obj.setCanDeal(false);
					gridsNeedUpdate.addAll(me.addObjectToPackage(obj, false));
				}
			}
			me.setLottery(me.getLottery() - price);
		}

		Mmochat_13_5S pack = new Mmochat_13_5S();
		try {
			MmochatDao.updateRoleLotteryAndPackage(me);
			pack.setMsg("兑换成功!请按3键打开包裹查看!");
			try {
				Mmochat_5_1S updatePack = new Mmochat_5_1S();
				updatePack.addGrid(gridsNeedUpdate);
				MmochatUtil.sendCommonPack(me, updatePack);
			} catch (Exception e) {
				e.printStackTrace();
			}
		} catch (Exception e) {
			e.printStackTrace();
			me.setMyPackage(packageBak);
			me.setLottery(me.getLottery() + price);
			pack.setMsg("服务器忙,请稍候兑换!");
		}

		pack.setBigMoney(me.getLottery());
		MmochatUtil.sendCommonPack(me, pack);

		return null;
	}

	// 13.19 使用奖券抽奖道具
	@SuppressWarnings("unchecked")
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_19(SkymobiHandler handler,
			Mmochat_13_19C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (MmochatConstant.shopClassVersion != req.getVersion()) {
			return MmochatUtil.msgbox(req.getHallState(), "您的版本过旧,请退出游戏重新进入!");
		}

		int lotteryNeed = 40; // 每次抽奖所需奖券数
		int num = req.getNum();
		if (num <= 0) {
			return MmochatUtil.msgbox(req.getHallState(), "数量必须大于0!");
		}
		MmochatObjectType objType = MmochatObjectType
				.get(req.getObjTypeValue());
		MmochatCommonObjectType type = null;
		boolean canOverlap = false;
		int price = 0;
		String objName;
		MmochatCommonObject newObj;
		switch (objType) {
		case 道具:
			MmochatPropType propType = MmochatPropType.get(req.getObjKey());
			canOverlap = propType.isCanOverLap();
			price = propType.getLottery() * num;
			objName = propType.toString();
			newObj = new MmochatProp(propType);
			if (canOverlap) {
				newObj.setOverlapNum(num);
			}
			type = propType;
			break;
		case 药品:
			MmochatDrugType drugType = MmochatDrugType.get(req.getObjKey());
			canOverlap = true;
			price = drugType.getPrice() * num;
			objName = drugType.toString();
			newObj = new MmochatDrug();
			newObj.setDrugType(drugType);
			if (canOverlap) {
				newObj.setOverlapNum(num);
			}
			type = drugType;
			break;
		case 装备:
			MmochatEquipType equipType = MmochatEquipType.get(req.getObjKey());
			int equipLevel = req.getEquipLevel();
			price = MmochatEquipService.getEquipPrice(equipType, equipLevel)
					* num;
			canOverlap = false;
			objName = MmochatEquipService.getEquipName(equipType, equipLevel);
			newObj = MmochatEquipService.createRandomEquip(true, equipType,
					equipLevel, MmochatEquipQualityType.白装);
			if (canOverlap) {
				newObj.setOverlapNum(num);
			}
			type = equipType;
			break;
		default:
			return MmochatUtil.msgbox(req.getHallState(), "此类物品暂不抽奖!");
		}
		if (newObj == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		// 抽奖
		Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
				.deepClone(me.getMyPackage(),
						new TypeToken<Map<Integer, MmochatPackageGrid>>() {
						}.getType());
		boolean hit = false; // 是否抽中
		int compensation = 0; // 补偿奖券数
		List<MmochatPackageGrid> gridsNeedUpdate = new ArrayList<MmochatPackageGrid>();
		synchronized (me) {
			if (me.getLottery() < lotteryNeed) {
				return MmochatUtil.msgbox(req.getHallState(), "您的奖券不足"
						+ lotteryNeed + ",无法进行抽奖!");
			}
			if (me.calRestPackageSpace(type, canOverlap, true) < num) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您的包裹空间不足!请先清理出空间再进行抽奖!");
			}

			// 计算是否抽中
			me.setLottery(me.getLottery() - lotteryNeed);
			double probability = Math.random();
			if (probability < (lotteryNeed * 1.0 / 2 / price)) {
				hit = true;
			}

			// 抽中
			if (hit == true) {
				if (canOverlap || num == 1) {
					newObj.setCanDeal(false);
					gridsNeedUpdate
							.addAll(me.addObjectToPackage(newObj, false));
				} else {
					for (int i = 0; i < num; i++) {
						MmochatCommonObject obj = newObj.getCloneWithNewId();
						obj.setCanDeal(false);
						gridsNeedUpdate.addAll(me
								.addObjectToPackage(obj, false));
					}
				}
			}
			// 没中，补偿少许奖券(0-10张)
			else {
				compensation = (int) (Math.random() * 11);
				me.setLottery(me.getLottery() + compensation);
			}
		}

		Mmochat_13_5S pack = new Mmochat_13_5S();
		if (hit == true) {
			try {
				MmochatDao.updateRoleLotteryAndPackage(me);
				pack.setMsg("恭喜您抽中了"
						+ MmochatUtil.wrapColor(objName, Color.yellow)
						+ " !请按3键打开包裹查看!");
				try {
					Mmochat_5_1S updatePack = new Mmochat_5_1S();
					updatePack.addGrid(gridsNeedUpdate);
					MmochatUtil.sendCommonPack(me, updatePack);
				} catch (Exception e) {
					e.printStackTrace();
				}
			} catch (Exception e) {
				e.printStackTrace();
				me.setMyPackage(packageBak);
				me.setLottery(me.getLottery() + lotteryNeed);
				pack.setMsg("服务器忙,请稍候抽奖!");
			}
		} else if (compensation != 0) {
			try {
				MmochatDao.updateRoleLotteryAndPackage(me);
				pack.setMsg("很遗憾,您没有抽中。作为补偿，您得到了" + compensation + "张奖券。");
				try {
					Mmochat_5_1S updatePack = new Mmochat_5_1S();
					updatePack.addGrid(gridsNeedUpdate);
					MmochatUtil.sendCommonPack(me, updatePack);
				} catch (Exception e) {
					e.printStackTrace();
				}
			} catch (Exception e) {
				e.printStackTrace();
				me.setMyPackage(packageBak);
				me.setLottery(Math.max(me.getLottery() + lotteryNeed
						- compensation, 0));
				pack.setMsg("服务器忙,请稍候抽奖!");
			}
		} else {
			try {
				MmochatDao.updateRoleLotteryAndPackage(me);
				pack.setMsg("很遗憾,您没有抽中。");
				try {
					Mmochat_5_1S updatePack = new Mmochat_5_1S();
					updatePack.addGrid(gridsNeedUpdate);
					MmochatUtil.sendCommonPack(me, updatePack);
				} catch (Exception e) {
					e.printStackTrace();
				}
			} catch (Exception e) {
				e.printStackTrace();
				me.setMyPackage(packageBak);
				me.setLottery(Math.max(me.getLottery() + lotteryNeed, 0));
				pack.setMsg("服务器忙,请稍候抽奖!");
			}
		}

		pack.setBigMoney(me.getLottery());
		MmochatUtil.sendCommonPack(me, pack);

		return null;
	}

	// 13.18 打开兑换子目录
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_18(SkymobiHandler handler,
			Mmochat_13_18C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		switch (req.getType()) {
		case 0: {
			Mmochat_13_4S pack = new Mmochat_13_4S();
			pack.setHallState(req.getHallState());
			pack.setShopType(MmochatShopType.奖券兑换);
			pack.setVersion(MmochatConstant.shopClassVersion);
			pack.setUseInputBox(true);
			pack.setTitle("兑换战斗道具");
			pack.setMoney(me.getLottery());
			pack.setObjType(MmochatObjectType.道具);

			MmochatPropType[] propList = new MmochatPropType[] {
					MmochatPropType.急急如律令, MmochatPropType.超级急急如律令,
					MmochatPropType.特级急急如律令, MmochatPropType.顶级急急如律令,
					MmochatPropType.天尊令, MmochatPropType.道尊令,
					MmochatPropType.驱兽令, MmochatPropType.驭兽令,
					MmochatPropType.传送符, MmochatPropType.龙涎香 };

			for (MmochatPropType propType : propList) {
				Mmochat_13_4S.ShopObjInfo objInfo = pack.new ShopObjInfo();
				objInfo.setKey(propType.getKey());
				objInfo.setEquipLevel(0);
				objInfo.setBmpId(propType.getBmpId());
				objInfo.setSellInfo(propType.getLotteryInfo());
				pack.addShopObj(objInfo);
			}
			return pack;
		}
		case 1: {
			Mmochat_13_4S pack = new Mmochat_13_4S();
			pack.setHallState(req.getHallState());
			pack.setShopType(MmochatShopType.奖券兑换);
			pack.setVersion(MmochatConstant.shopClassVersion);
			pack.setUseInputBox(true);
			pack.setTitle("兑换特色道具");
			pack.setMoney(me.getLottery());
			pack.setObjType(MmochatObjectType.道具);

			MmochatPropType[] propList = new MmochatPropType[] {
					MmochatPropType.会员周卡, MmochatPropType.会员月卡,
					MmochatPropType.成长丹, MmochatPropType.超级成长丹,
					MmochatPropType.血量成长丹, MmochatPropType.物攻成长丹,
					MmochatPropType.法攻成长丹, MmochatPropType.速度成长丹,
					MmochatPropType.物防成长丹, MmochatPropType.法防成长丹,
					MmochatPropType.轮回水, MmochatPropType.超级轮回水,
					MmochatPropType.迟滞水, MmochatPropType.八卦令,
					MmochatPropType.超级八卦令, MmochatPropType.银联卡,
					MmochatPropType.赎罪牌, MmochatPropType.后悔药,
					MmochatPropType.超级后悔药, MmochatPropType.洗髓丹,
					MmochatPropType.超级洗髓丹, MmochatPropType.江湖名号,
					MmochatPropType.超级炼丹剂, MmochatPropType.照妖镜 };

			for (MmochatPropType propType : propList) {
				Mmochat_13_4S.ShopObjInfo objInfo = pack.new ShopObjInfo();
				objInfo.setKey(propType.getKey());
				objInfo.setEquipLevel(0);
				objInfo.setBmpId(propType.getBmpId());
				objInfo.setSellInfo(propType.getLotteryInfo());
				pack.addShopObj(objInfo);
			}
			return pack;
		}
		case 2: {
			Mmochat_13_4S pack = new Mmochat_13_4S();
			pack.setHallState(req.getHallState());
			pack.setShopType(MmochatShopType.奖券兑换);
			pack.setVersion(MmochatConstant.shopClassVersion);
			pack.setUseInputBox(true);
			pack.setTitle("兑换装备法宝");
			pack.setMoney(me.getLottery());
			pack.setObjType(MmochatObjectType.道具);

			MmochatPropType[] propList = new MmochatPropType[] {
					MmochatPropType.混沌石, MmochatPropType.超级改造石,
					MmochatPropType.超级白水晶, MmochatPropType.粉水晶,
					MmochatPropType.金水晶, MmochatPropType.绿水晶,
					MmochatPropType.强化水晶, MmochatPropType.升级石,
					MmochatPropType.神行法宝残片, MmochatPropType.神行法宝灵气丹,
					MmochatPropType.神行法宝聚灵丹, MmochatPropType.神行法宝体力丹 };

			for (MmochatPropType propType : propList) {
				Mmochat_13_4S.ShopObjInfo objInfo = pack.new ShopObjInfo();
				objInfo.setKey(propType.getKey());
				objInfo.setEquipLevel(0);
				objInfo.setBmpId(propType.getBmpId());
				objInfo.setSellInfo(propType.getLotteryInfo());
				pack.addShopObj(objInfo);
			}
			return pack;
		}
		default:
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
	}

	// 13.20 打开抽奖子目录
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_20(SkymobiHandler handler,
			Mmochat_13_20C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		switch (req.getType()) {
		case 0: {
			Mmochat_13_4S pack = new Mmochat_13_4S();
			pack.setHallState(req.getHallState());
			pack.setShopType(MmochatShopType.奖券抽奖);
			pack.setVersion(MmochatConstant.shopClassVersion);
			pack.setUseInputBox(false);
			pack.setTitle("抽奖战斗道具");
			pack.setMoney(me.getLottery());
			pack.setObjType(MmochatObjectType.道具);

			MmochatPropType[] propList = new MmochatPropType[] {
					MmochatPropType.急急如律令, MmochatPropType.超级急急如律令,
					MmochatPropType.特级急急如律令, MmochatPropType.顶级急急如律令,
					MmochatPropType.天尊令, MmochatPropType.道尊令,
					MmochatPropType.驱兽令, MmochatPropType.驭兽令,
					MmochatPropType.传送符, MmochatPropType.龙涎香 };

			for (MmochatPropType propType : propList) {
				Mmochat_13_4S.ShopObjInfo objInfo = pack.new ShopObjInfo();
				objInfo.setKey(propType.getKey());
				objInfo.setEquipLevel(0);
				objInfo.setBmpId(propType.getBmpId());
				objInfo.setSellInfo(propType.getRaffleInfo());
				pack.addShopObj(objInfo);
			}
			return pack;
		}
		case 1: {
			Mmochat_13_4S pack = new Mmochat_13_4S();
			pack.setHallState(req.getHallState());
			pack.setShopType(MmochatShopType.奖券抽奖);
			pack.setVersion(MmochatConstant.shopClassVersion);
			pack.setUseInputBox(false);
			pack.setTitle("抽奖特色道具");
			pack.setMoney(me.getLottery());
			pack.setObjType(MmochatObjectType.道具);

			MmochatPropType[] propList = new MmochatPropType[] {
					MmochatPropType.会员周卡, MmochatPropType.会员月卡,
					MmochatPropType.成长丹, MmochatPropType.超级成长丹,
					MmochatPropType.血量成长丹, MmochatPropType.物攻成长丹,
					MmochatPropType.法攻成长丹, MmochatPropType.速度成长丹,
					MmochatPropType.物防成长丹, MmochatPropType.法防成长丹,
					MmochatPropType.轮回水, MmochatPropType.超级轮回水,
					MmochatPropType.迟滞水, MmochatPropType.八卦令,
					MmochatPropType.超级八卦令, MmochatPropType.银联卡,
					MmochatPropType.赎罪牌, MmochatPropType.后悔药,
					MmochatPropType.超级后悔药, MmochatPropType.洗髓丹,
					MmochatPropType.超级洗髓丹, MmochatPropType.江湖名号,
					MmochatPropType.超级炼丹剂, MmochatPropType.照妖镜 };

			for (MmochatPropType propType : propList) {
				Mmochat_13_4S.ShopObjInfo objInfo = pack.new ShopObjInfo();
				objInfo.setKey(propType.getKey());
				objInfo.setEquipLevel(0);
				objInfo.setBmpId(propType.getBmpId());
				objInfo.setSellInfo(propType.getRaffleInfo());
				pack.addShopObj(objInfo);
			}
			return pack;
		}
		case 2: {
			Mmochat_13_4S pack = new Mmochat_13_4S();
			pack.setHallState(req.getHallState());
			pack.setShopType(MmochatShopType.奖券抽奖);
			pack.setVersion(MmochatConstant.shopClassVersion);
			pack.setUseInputBox(false);
			pack.setTitle("抽奖装备法宝");
			pack.setMoney(me.getLottery());
			pack.setObjType(MmochatObjectType.道具);

			MmochatPropType[] propList = new MmochatPropType[] {
					MmochatPropType.混沌石, MmochatPropType.超级改造石,
					MmochatPropType.超级白水晶, MmochatPropType.粉水晶,
					MmochatPropType.金水晶, MmochatPropType.绿水晶,
					MmochatPropType.强化水晶, MmochatPropType.升级石,
					MmochatPropType.神行法宝残片, MmochatPropType.神行法宝灵气丹,
					MmochatPropType.神行法宝聚灵丹, MmochatPropType.神行法宝体力丹 };

			for (MmochatPropType propType : propList) {
				Mmochat_13_4S.ShopObjInfo objInfo = pack.new ShopObjInfo();
				objInfo.setKey(propType.getKey());
				objInfo.setEquipLevel(0);
				objInfo.setBmpId(propType.getBmpId());
				objInfo.setSellInfo(propType.getRaffleInfo());
				pack.addShopObj(objInfo);
			}
			return pack;
		}
		default:
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
	}

	// 13.6 兑换元宝
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_6(SkymobiHandler handler,
			Mmochat_13_6C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		int num = 0;
		try {
			num = Integer.parseInt(req.getKb());
		} catch (NumberFormatException e) {
			return MmochatUtil.msgbox(req.getHallState(),
					"只能输入数字,请重新输入要兑换的K币数!");
		}
		if (num <= 0) {
			return MmochatUtil.msgbox(req.getHallState(), "请输入大于0的数字!");
		}
		if (num >= 200000) {
			return MmochatUtil.msgbox(req.getHallState(),
					"一次兑换不能超过200000K币,请重新输入!");
		}

		boolean success;
		synchronized (me) {
			int kbRest = CurrService.handleQueryCurrency(req.getSkyId());
			if (kbRest == -1) {
				return MmochatUtil.msgbox(req.getHallState(),
						"服务器忙,K币查询失败,请稍候再试!");
			}
			if (kbRest < num) {
				return MmochatUtil.msgbox(req.getHallState(), "您的K币余额不足,当前只有"
						+ kbRest + "K币!");
			}
			success = CurrService.handleModifyCurrency(req.getSkyId(),
					-1 * num, MmochatConstant.REASON_ID_兑换元宝);
		}
		if (success) {
			int addMoney = num * MmochatConstant.getExchangeRate() / 100;
			int addAwardTimes = addMoney / MmochatConstant.payValuePerAward;

			try {
				try {
					MmochatPropService.setFirstPayAward(me);
				} catch (Exception e1) {
					e1.printStackTrace();
				}

				MmochatDao.createNewKbOrder(me.getRoleId(), me.getSkyId(), num,
						addMoney, addAwardTimes, me.getDao(), me.getExp());
				me.setLatest_pay_time(System.currentTimeMillis());
				try {
					me.addBig_money(addMoney);
					me.addRest_award_times(addAwardTimes);

					MmochatStatisticsService.addBigMoneyEarn(
							MmochatBigMoneyEarnType.K币兑换, addMoney);

					CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
					String showContent = "兑换成功!您获得了"
							+ MmochatUtil
									.wrapColor(addMoney + "", Color.yellow)
							+ "元宝!";
					if (addAwardTimes != 0) {
						showContent += "并获得了"
								+ MmochatUtil.wrapColor(addAwardTimes + "",
										Color.green) + "次充值抽奖活动的机会!";
					}
					msgbox.setContent(new Text(showContent));
					msgbox.setLeftName("确定");

					CreateTlvWin tlv = getPaymentPage(me);
					// 统计KB兑换
					Integer count = MmochatStatisticsService.todayKBPayMap
							.get(me.getRoleId());
					if (count == null) {
						// 今天第一次统计
						MmochatStatisticsService.todayKBPayMap.put(me
								.getRoleId(), num);
					} else {
						count += num;
						MmochatStatisticsService.todayKBPayMap.put(me
								.getRoleId(), count);
					}
					MmochatStatisticsService.todayKBPayTimes++;

					// 即开型充值抽奖
					dealFastPayLottery(me, num);

					// 给推荐人发放奖励
					try {
						if (me.getSuggestName() != null
								&& me.getSuggestName().length() > 0) {
							long lifeTime = System.currentTimeMillis()
									- me.getCreateTime();
							int awardCount = 0;
							if (lifeTime < MmochatConstant.MS_PER_DAY * 30) {
								// 创建角色30天以内，奖励20%
								awardCount = num / 5;
							} else if (lifeTime < MmochatConstant.MS_PER_DAY * 60) {
								// 创建角色60天以内，奖励10%
								awardCount = num / 10;
							}
							if (awardCount > 0) {
								String suggestName = me.getSuggestName();
								int suggestRoleId = -1;
								int zoneId = -1;
								boolean ret = false;
								do {
									int index = suggestName.indexOf("区");
									if (index == -1) {
										break;
									}
									String zoneStr = suggestName.substring(0,
											index);
									String suggestRoleIdStr = suggestName
											.substring(index + 1);
									try {
										zoneId = Integer.parseInt(zoneStr);
										suggestRoleId = Integer
												.parseInt(suggestRoleIdStr);
									} catch (NumberFormatException e) {
										break;
									}
									ret = true;
								} while (false);

								// 推荐人格式正确
								if (ret) {
									Integer dstModuleId = MmochatMain
											.getInstanceIdByServerId(zoneId);
									if (dstModuleId != null) {
										// 推荐人与此玩家是同一区服
										if (dstModuleId == MmochatMain
												.getModuleInstID()) {
											// 先在数据库中增加积分
											int row = 0;
											try {
												row = MmochatDao
														.addSuggestScore(
																awardCount,
																suggestRoleId);
											} catch (Exception e) {
												e.printStackTrace();
											}
											if (row > 0) {
												MmochatPlayer suggester = MmochatMainService
														.getRoleFromBuffer(suggestRoleId);
												if (suggester != null) {
													// 在线
													suggester
															.addSuggestScore(awardCount);
												}
												// 下发客服消息
												String content = MmochatUtil
														.wrapColor("恭喜恭喜!",
																Color.red)
														+ "您推荐的玩家"
														+ MmochatUtil
																.wrapColor(
																		me
																				.getName(),
																		Color.green)
														+ "(本区服)在游戏里兑换了"
														+ MmochatUtil
																.wrapColor(
																		num
																				+ "K币",
																		Color.yellow)
														+ "，您因此获得了"
														+ MmochatUtil
																.wrapColor(
																		awardCount
																				+ "积分",
																		Color.yellow)
														+ "的奖励。请再接再励，继续推荐其它朋友一起来玩。";
												MmochatGmService
														.sendKufuPrivateMsg(
																suggestRoleId,
																content, false);
											}
										} else {
											// 跨服发送奖励
											Mmochat_SendSuggestAward pack = new Mmochat_SendSuggestAward();
											pack.setSrcModuleId(MmochatMain
													.getModuleInstID());
											pack.setDstModuleId(dstModuleId);
											pack
													.setSuggestRoleId(suggestRoleId);
											pack.setAwardCount(awardCount);
											String zoneName = "";
											if (MmochatMain.getServerName() != null) {
												zoneName = "("
														+ MmochatMain
																.getServerName()
														+ "区)";
											}
											String content = MmochatUtil
													.wrapColor("恭喜恭喜!",
															Color.red)
													+ "您推荐的玩家"
													+ MmochatUtil.wrapColor(me
															.getName(),
															Color.green)
													+ zoneName
													+ "在游戏里兑换了"
													+ MmochatUtil.wrapColor(num
															+ "K币",
															Color.yellow)
													+ "，您因此获得了"
													+ MmochatUtil.wrapColor(
															awardCount + "积分",
															Color.yellow)
													+ "的奖励。请再接再励，继续推荐其它朋友一起来玩。";
											pack.setAwardMsg(content);
											SkymobiHandler handle = MmochatMainService
													.getCommonHandler();
											if (handle != null) {
												handle
														.asyncPushSkymobiModuleMessage(
																pack, null);
											}
										}
									}
								}
							}
						}
					} catch (Exception e) {
						e.printStackTrace();
					}

					// 限时充值抽大奖活动
					if (MmochatPropService.payLotteryInfo != null
							&& MmochatPropService.payLotteryInfo.getState() == MmochatPayLotteryState.开始统计) {
						MmochatPropService.payLotteryInfo.addRolePay(me, num);
					}

					return MmochatUtil.tlvResponse(req.getHallState(),
							new CloseWinTLV(MmochatConstant.TLV_WIN_PAYMENT),
							tlv, msgbox);
				} catch (Exception e) {
					return MmochatUtil.msgbox(req.getHallState(), "兑换成功!");
				}
			} catch (Exception e) {
				e.printStackTrace();
				// 保存数据库失败,增加日志记录
				// 补还K币失败,写入mmochat_dealKB_error.log文件
				try {
					Date now = new Date();
					SimpleDateFormat dayFormat = new SimpleDateFormat(
							"yyyy_MM_dd");
					String day = dayFormat.format(now);
					SimpleDateFormat secFormat = new SimpleDateFormat(
							"HH:mm:ss");
					String sec = secFormat.format(now);

					String logInfo = sec + "\t";
					logInfo += "roleId:" + me.getRoleId() + ",\t";
					logInfo += "addBigMoney:" + addMoney + ",\t";
					logInfo += "addAwardTimes:" + addAwardTimes + ",\t";
					logInfo += "kb:" + num + ",name:" + me.getName()
							+ ",skyId=" + me.getSkyId();

					MmochatUtil.writeToFile(
							"Kb2BigmoneyFailed_" + day + ".log", logInfo);
				} catch (Exception e1) {
					e1.printStackTrace();
				}

				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				msgbox.setContent(new Text("亲爱的玩家,非常抱歉!由于系统繁忙,"
						+ MmochatUtil.wrapColor("K币兑换失败,但您的K币已被扣除", Color.red)
						+ "!" + "我们已经记录了本次兑换操作,请按#键打开好友面板,通过里面的"
						+ MmochatUtil.wrapColor("在线客服", Color.magenta)
						+ "联系我们,"
						+ MmochatUtil.wrapColor("我们会及时为您补回元宝", Color.green)
						+ "。对您造成的不便,请见谅!"));
				msgbox.setLeftName("确定");

				CreateTlvWin tlv = getPaymentPage(me);

				return MmochatUtil.tlvResponse(req.getHallState(),
						new CloseWinTLV(MmochatConstant.TLV_WIN_PAYMENT), tlv,
						msgbox);
			}
		} else {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,K币扣除失败,请稍候再试!");
		}
	}

	// 使用血池法池效果,不负责保存数据库
	public static void useAutoAddBloodSpritProp(MmochatPlayer me) {
		try {
			MmochatPet pet = me.getPkPet();
			MmochatPet bakPet = me.getBakPkPet();

			int needBlood = me.getTotalBlood() - me.getCurBlood();
			int needSprit = me.getTotalSprit() - me.getCurSprit();
			int petNeedBlood = 0, petNeedSprit = 0;
			int bakPetNeedBlood = 0, bakPetNeedSprit = 0;
			if (pet != null) {
				petNeedBlood = pet.getTotalBlood() - pet.getCurBlood();
				petNeedSprit = pet.getTotalSprit() - pet.getCurSprit();
			}
			if (bakPet != null) {
				bakPetNeedBlood = bakPet.getTotalBlood() - bakPet.getCurBlood();
				bakPetNeedSprit = bakPet.getTotalSprit() - bakPet.getCurSprit();
			}
			synchronized (me) {
				MmochatPropEffect bloodEffect = me.getPropEffects().get(
						MmochatPropType.小血池.getEffectKey());
				if (bloodEffect != null) {
					if (needBlood > 0) {
						// 给人补血,直接补满
						if (bloodEffect.getRestAmount() > 0) {
							int bloodNeed = (int) Math.min(needBlood,
									bloodEffect.getRestAmount());
							bloodEffect.addAmount(-1 * bloodNeed);
							me.addCurBlood(bloodNeed);
						}
					}
					if (petNeedBlood > 0) {
						// 给宠补血,直接补满
						if (bloodEffect.getRestAmount() > 0) {
							int bloodNeed = (int) Math.min(petNeedBlood,
									bloodEffect.getRestAmount());
							bloodEffect.addAmount(-1 * bloodNeed);
							pet.addCurBlood(bloodNeed);
						}
					}
					if (bakPetNeedBlood > 0) {
						// 给宠补血,直接补满
						if (bloodEffect.getRestAmount() > 0) {
							int bloodNeed = (int) Math.min(bakPetNeedBlood,
									bloodEffect.getRestAmount());
							bloodEffect.addAmount(-1 * bloodNeed);
							bakPet.addCurBlood(bloodNeed);
						}
					}

					if (bloodEffect.getRestAmount() <= 0) {
						me.delPropEffect(MmochatPropType.小血池.getEffectKey());
					}
				}
				MmochatPropEffect spritEffect = me.getPropEffects().get(
						MmochatPropType.小法池.getEffectKey());
				if (spritEffect != null) {
					if (needSprit > 0) {
						// 给人补法,直接补满
						if (spritEffect.getRestAmount() > 0) {
							int spritNeed = (int) Math.min(needSprit,
									spritEffect.getRestAmount());
							spritEffect.addAmount(-1 * spritNeed);
							me.addCurSprit(spritNeed);
						}
					}
					if (petNeedSprit > 0) {
						// 给宠补法,直接补满
						if (spritEffect.getRestAmount() > 0) {
							int spritNeed = (int) Math.min(petNeedSprit,
									spritEffect.getRestAmount());
							spritEffect.addAmount(-1 * spritNeed);
							pet.addCurSprit(spritNeed);
						}
					}
					if (bakPetNeedSprit > 0) {
						// 给宠补法,直接补满
						if (spritEffect.getRestAmount() > 0) {
							int spritNeed = (int) Math.min(bakPetNeedSprit,
									spritEffect.getRestAmount());
							spritEffect.addAmount(-1 * spritNeed);
							bakPet.addCurSprit(spritNeed);
						}
					}
					if (spritEffect.getRestAmount() <= 0) {
						me.delPropEffect(MmochatPropType.小法池.getEffectKey());
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	// 使用全队传送符
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_9(SkymobiHandler handler,
			Mmochat_13_9C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (me.hasYBTask()) {
			return MmochatUtil.msgbox(req.getHallState(),
					"押送镖银过程中无法使用传送符!您需要先放弃或完成此任务!");
		}

		MmochatPackageGrid grid;
		MmochatCommonObject prop;
		short x;
		short y;

		MmochatMap newMap;
		List<MmochatPlayer> members;
		synchronized (me) {
			grid = me.getMyPackage().get(req.getGridId());
			if (grid == null) {
				return MmochatUtil.msgbox(req.getHallState(), "您没有传送符，请先购买!");
			}
			prop = grid.getObject();
			if (prop == null || prop.getPropType() != MmochatPropType.传送符
					|| prop.isUsedOut()) {
				return MmochatUtil.msgbox(req.getHallState(), "您没有传送符，请先购买!");
			}
			int mapId = req.getMapId();
			x = req.getX();
			y = req.getY();
			// 将全队传送到指定坐标
			if (me.isInBattle()) {
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")已进入战斗,无法传送");
				return null;
			}
			newMap = MmochatMapService.getMapByMapId(mapId);
			if (newMap == null) {
				return MmochatUtil
						.msgbox(req.getHallState(), "目标地图已关闭，暂时无法前往!");
			}
			members = new ArrayList<MmochatPlayer>();
			if (me.isInTeam()) {
				MmochatTeam team = MmochatTeamService.teams.get(me.getTeamId());
				if (team == null) {
					me.leaveTeam();
					members.add(me);
				} else {
					if (!team.isTeamLeader(me.getRoleId())) {
						log.debug("玩家" + me.getName() + "(skyid="
								+ me.getSkyId() + ")在队伍中，且不为队长，无法传送;");
						return MmochatUtil.msgbox(req.getHallState(),
								"您在队伍中，请和队长一起行动!");
					}
					for (Integer roleId : team.getMemberId().values()) {
						MmochatPlayer member = MmochatMainService.players
								.get(roleId);
						if (member != null) {
							members.add(member);
						}
					}
				}
			} else {
				members.add(me);
			}
			if (members.size() <= 0) {
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")传送人数为0，无法传送;");
				return null;
			}
			// 消耗传送符
			prop.use(1);
			if (prop.isUsedOut()) {
				grid.setObject(null);
				MmochatStatisticsService.addPropCost(MmochatPropType.传送符, 1);
			}
		}

		if (!needToSavePropSqlPlayerQueue.contains(me)
				&& !MmochatGmService.isSystemExit()) {
			needToSavePropSqlPlayerQueue.add(me);
		}

		Mmochat_5_1S pack = new Mmochat_5_1S();
		pack.addGrid(grid);
		MmochatUtil.sendCommonPack(me, pack);

		// 通过x,y决定传送到哪个地图哪个传送口附近
		MmochatMap curMap = MmochatMapService.getMapByMapId(me.getMapId());

		// 将本队人马传到新地图新坐标
		MmochatMapService.tranToNewMap(curMap, me.getLine(), newMap, me
				.getLine(), x, y, members);
		log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId() + ")完成传送");

		return null;
	}

	// 领取神行法宝
	@SuppressWarnings("unchecked")
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_11(SkymobiHandler handler,
			Mmochat_13_11C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		// 检查包裹空位
		if (!me.hasEnoughPackageSpace(1)) {
			return MmochatUtil.msgbox(req.getHallState(), "您的包裹已满,请先整理出一个空位!");
		}

		// 检查5个神行法宝残片
		if (me.getPackageObjNum(MmochatPropType.神行法宝残片) < 5) {
			return MmochatUtil.msgbox(req.getHallState(), "您的可用包裹里没有足够的"
					+ MmochatUtil.wrapColor(MmochatPropType.神行法宝残片.toString(),
							Color.yellow) + ",您可以按9键在商城中购买。");
		}

		// 备份包裹
		Map<Integer, MmochatPackageGrid> myPackageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
				.deepClone(me.getMyPackage(),
						new TypeToken<Map<Integer, MmochatPackageGrid>>() {
						}.getType());

		// 扣除残片、增加神行法宝
		boolean ret = me.delPackageObj(MmochatPropType.神行法宝残片, 5);
		if (!ret) {
			me.setMyPackage(myPackageBak);
			return MmochatUtil.msgbox(req.getHallState(), "您的可用包裹里没有足够的"
					+ MmochatPropType.神行法宝残片.toString() + ",您可以按9键在商城中购买。");
		}
		MmochatSuperMachine s = new MmochatSuperMachine(
				MmochatSuperMachineType.神行法宝);
		s.setFlyMachineCanUseTotalValue(3000);
		s.setFlyMachineCanUseValue(3000);
		ret = me.addObjectToPackage(s);
		if (!ret) {
			me.setMyPackage(myPackageBak);
			return MmochatUtil.msgbox(req.getHallState(), "您的包裹已满,请先整理出一个空位!");
		}

		try {
			MmochatDao.updateMyPackage(me);
		} catch (Exception e) {
			e.printStackTrace();
			me.setMyPackage(myPackageBak);
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatStatisticsService.addPropCost(MmochatPropType.神行法宝残片, 5);
		return MmochatUtil.msgbox(req.getHallState(), "您获得了神行法宝:"
				+ MmochatUtil.wrapColor(s.getName(), Color.yellow) + "!");
	}

	// 升级神行法宝
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_12(SkymobiHandler handler,
			Mmochat_13_12C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		// 检查是否有使用中的神行法宝
		MmochatPackageGrid grid = me.getMyPackage().get(
				MmochatSuperMachineType.神行法宝.getGridId());
		if (grid == null || grid.getObject() == null) {
			return MmochatUtil.msgbox(req.getHallState(),
					"请先将您需要升级的神行法宝设置为使用中(打开包裹，点击法宝，选择菜单中的<使用>)!");
		}
		MmochatCommonObject superMachine = grid.getObject();
		// 检查神行法宝是否已经满级
		int curSpeedLevel = superMachine.getFlyMachineSpeedLevel();
		int curFlyLevel = superMachine.getFlyMachineFlyLevel();
		if (curSpeedLevel == MmochatCommonObject.flyMachineMaxSpeedLevel
				&& curFlyLevel == MmochatCommonObject.flyMachineMaxFlyLevel) {
			return MmochatUtil.msgbox(req.getHallState(),
					"您当前使用中的神行法宝已满级，无法再升级!");
		}
		// 检查神行法宝灵气是否足够升级
		int uplevelExp = MmochatCommonObject.getFlyMachineUplevelNeed(
				curSpeedLevel, curFlyLevel);
		if (superMachine.getFlyMachineExp() < uplevelExp) {
			return MmochatUtil.msgbox(req.getHallState(),
					"您当前使用中的神行法宝灵气未达到升级条件，无法升级!");
		}

		MmochatCommonObject superMachineBak = superMachine.getClone();
		// 更新法宝体力
		if (superMachine.getFlyMachineCanUseTotalValue() > 0) {
			Date now = new Date();
			long lastTime = now.getTime()
					- superMachine.getFlyMachineUseStartTime();
			if (lastTime > 0) {
				long hour = lastTime / MmochatConstant.MS_PER_HOUR;
				long useValue = hour
						* MmochatCommonObject.getFlyMachineUsePerHour(
								superMachine.getFlyMachineSpeedLevel(),
								superMachine.getFlyMachineFlyLevel());
				long restValue = superMachine.getFlyMachineCanUseTotalValue()
						- useValue;
				if (restValue <= 0) {
					restValue = 0;
				}
				superMachine.setFlyMachineCanUseTotalValue(restValue);
				superMachine.setFlyMachineCanUseValue(restValue);
				superMachine.setFlyMachineUseStartTime(now.getTime());
			}
		}
		// 开始升级：法宝升级，扣除灵气
		String msg = "恭喜!您的神行法宝升级了，";
		superMachine.delFlyMachineExp(uplevelExp);
		if (curSpeedLevel < MmochatCommonObject.flyMachineMaxSpeedLevel) {
			superMachine.setFlyMachineSpeedLevel(curSpeedLevel + 1);
			msg += MmochatUtil.wrapColor("移动能力提升到" + (curSpeedLevel + 1) + "阶",
					Color.yellow)
					+ "。";
		} else if (curFlyLevel < MmochatCommonObject.flyMachineMaxFlyLevel) {
			superMachine.setFlyMachineFlyLevel(curFlyLevel + 1);
			msg += MmochatUtil.wrapColor("腾空能力提升到" + (curFlyLevel + 1) + "阶",
					Color.yellow)
					+ "(达到5阶时可以飞越障碍物)。";
		}
		try {
			MmochatDao.updateMyPackage(me);
		} catch (Exception e) {
			e.printStackTrace();
			grid.setObject(superMachineBak);
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		// 更新包裹
		Mmochat_5_1S pack = new Mmochat_5_1S();
		pack.addGrid(grid);
		MmochatUtil.sendCommonPack(me, pack);

		// 更新人物状态
		Mmochat_1_16S pack2 = new Mmochat_1_16S();
		pack2.setMe(me);
		MmochatUtil.sendCommonPack(me, pack2);

		return MmochatUtil.msgbox(req.getHallState(), msg);
	}

	// 抢购便宜货
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_15(SkymobiHandler handler,
			Mmochat_13_15C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
		if (hour < 12) {
			return MmochatUtil.msgbox(req.getHallState(),
					"促销活动12:00-24:00进行，现在不是活动时间!");
		}
		if (!MmochatConstant.isShopDiscountActivityOpen()) {
			return MmochatUtil.msgbox(req.getHallState(), "促销活动目前未开启!");
		}
		// 购买道具
		MmochatPropType propType = MmochatConstant.getDiscountPropType();
		if (propType == null) {
			return MmochatUtil.msgbox(req.getHallState(), "此活动暂未开启!");
		}

		if (me.getBig_money() < propType.getPrice()) {
			return MmochatUtil.msgbox(req.getHallState(), "至少需要有"
					+ MmochatUtil.wrapColor(propType.getPrice(), Color.yellow)
					+ "元宝才能参加本次活动，您的元宝不足，请先充值。");
		}

		if (me.calRestPackageSpace(propType, propType.isCanOverLap(), true) < 1) {
			return MmochatUtil
					.msgbox(req.getHallState(), "您的包裹空间不足，请至少预留一个空位!");
		}

		int price;
		String disCount;
		String sysMsg = null;

		// 1折到8.8折概率分布(平均7折)
		// 1-3折:4.2%
		// 3-5折:6.3%
		// 5-7折:20%
		// 7-8.8折:69%
		double curDiscount;
		int rand = MmochatUtil.getRandomValue(1000);
		if (rand < 42) {
			// 1-3折
			int v = MmochatUtil.getRandomValue(10, 30);
			curDiscount = v / 100.0;
			sysMsg = MmochatUtil.wrapColor(me.getName(), Color.green)
					+ "鸿运当头，在打折促销活动中成功以";
		} else if (rand < 105) {
			// 3-5折
			int v = MmochatUtil.getRandomValue(30, 50);
			curDiscount = v / 100.0;
			sysMsg = MmochatUtil.wrapColor(me.getName(), Color.green)
					+ "手气不错，在打折促销活动中成功以";
		} else if (rand < 305) {
			// 5-7折
			int v = MmochatUtil.getRandomValue(50, 70);
			curDiscount = v / 100.0;
		} else {
			// 7-8.8折
			int v = MmochatUtil.getRandomValue(70, 88);
			curDiscount = v / 100.0;
		}
		DecimalFormat df = new DecimalFormat("0.0");

		price = (int) (propType.getPrice() * curDiscount);
		price = Math.max(1, price);
		disCount = price
				+ "元宝("
				+ MmochatUtil.wrapColor(df.format(curDiscount * 10) + "折",
						Color.yellow) + ")";
		if (sysMsg != null) {
			sysMsg += disCount + "的低价购得一个"
					+ MmochatUtil.wrapColor(propType.toString(), Color.yellow)
					+ "!";
		}

		if (price <= 0) {
			return MmochatUtil.msgbox(req.getHallState(), "道具价格异常!");
		}
		if (me.getBig_money() < price) {
			return MmochatUtil.msgbox(req.getHallState(), "您的元宝不足!请先充值元宝!");
		}

		// 购买
		MmochatProp newObj = new MmochatProp(propType);
		synchronized (me) {
			if (me.getBig_money() < price) {
				return MmochatUtil.msgbox(req.getHallState(), "您的元宝不足!请先充值元宝!");
			}
			if (me.calRestPackageSpace(propType, propType.isCanOverLap(), true) < 1) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您的包裹空间不足，请至少预留一个空位!");
			}
			me.addObjectToPackage(newObj);
			me.addBig_money(-1 * price);
		}
		long oldLimit = me.getLimit_bigmoney();
		me.addLimit_bigmoney(-1 * price);
		try {
			MmochatDao.buyBigMoneyObj(me, price);
		} catch (Exception e) {
			e.printStackTrace();
			me.delPackageObjById(newObj.getId());
			me.addBig_money(price);
			me.setLimit_bigmoney(oldLimit);
			return MmochatUtil.msgbox(req.getHallState(), "同时购买人数过多，请稍候再试!");
		}
		MmochatBigMoneyCostType earnType = MmochatBigMoneyCostType
				.valueOf(propType.toString());
		if (earnType != null) {
			MmochatStatisticsService.addBigMoneyCost(earnType, -1 * price);
		}

		String msg = "恭喜!您以" + disCount + "的价格购买到了一个" + propType.toString()
				+ "!";
		MmochatChatService.sendSystemMsg(sysMsg);
		return MmochatUtil.msgbox(req.getHallState(), msg);
	}

	// 13.16 充值抽奖
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_16(SkymobiHandler handler,
			Mmochat_13_16C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (me.getRest_award_times() <= 0) {
			return MmochatUtil.msgbox(req.getHallState(),
					"您的可抽奖次数为0，无法抽奖。充值或兑换" + MmochatConstant.payValuePerAward
							+ "元宝即可获得1次抽奖机会。");
		}
		if (!me.hasEnoughPackageSpace(1)) {
			return MmochatUtil
					.msgbox(req.getHallState(), "请先清理出一个包裹空间，以免奖品掉落!");
		}
		if (me.isPetFull()) {
			return MmochatUtil.msgbox(req.getHallState(),
					"您携带的宠物数已达上限，无法抽奖。请先整理出一个宠物空间!");
		}
		synchronized (me) {
			if (me.getRest_award_times() <= 0) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您的可抽奖次数为0，无法抽奖。充值或兑换"
								+ MmochatConstant.payValuePerAward
								+ "元宝即可获得1次抽奖机会。");
			}
			// 先扣除次数，如果抽奖失败，则补回次数
			me.delRest_award_times(1);
		}
		// 抽奖:充30给3块钱
		// 神兽，8级神行法宝，10万积分(价值都算作1000块钱，千分之一的概率，期望值1块钱)
		// 道具、首饰、套装材料、金钱、道行(期望值200元宝)
		if (MmochatUtil.isInPercent(0.1)) {
			// 中大奖了
			int index = (int) (Math.random() * 2);
			switch (index) {
			case 0: {
				// 神兽
				MmochatRoleType[] list = new MmochatRoleType[] {
						MmochatRoleType.高力玄武, MmochatRoleType.通灵玄武,
						MmochatRoleType.铁血玄武, MmochatRoleType.幻影玄武 };
				int itemIndex = MmochatUtil.getRandomValue(list.length);
				MmochatRoleType type = list[itemIndex];
				MmochatPet pet = MmochatPetService.createPetByType(type);
				if (pet != null) {
					me.addPet(pet);
					try {
						MmochatDao.updateRoleAfterAward(me, 0);
					} catch (Exception e) {
						e.printStackTrace();
						me.delRest_award_times(-1);
						me.delPet(pet.getId());
						return MmochatUtil.msgbox(req.getHallState(),
								"服务器忙,请稍候再试!");
					}

					Mmochat_5_10S pack = new Mmochat_5_10S();
					pack.addPet(pet);
					MmochatUtil.sendCommonPack(me, pack);

					String sysInfo = "哇!"
							+ MmochatUtil.wrapColor(me.getName(), Color.green)
							+ "在充值抽奖活动中喜中大奖，得到一个"
							+ MmochatUtil.wrapColor(pet.getPetTypeName(),
									Color.yellow) + "!朋友们快找他请客呀~";
					sysInfo = MmochatUtil.wrapColor(sysInfo, Color.red);
					MmochatChatService.sendSystemMsg(sysInfo);

					String myInfo = "恭喜恭喜!您喜中大奖，获得一个"
							+ MmochatUtil.wrapColor(pet.getPetTypeName(),
									Color.yellow) + "，快按0键打开宠物信息看看吧!";
					CreateTlvWin tlv = getPayAwardTlv(me);
					CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
					msgbox.setContent(new Text(myInfo));
					msgbox.setLeftName("确定");

					return MmochatUtil.tlvResponse(req.getHallState(),
							new CloseWinTLV(MmochatConstant.TLV_WIN_AWARD),
							tlv, msgbox);
				}
				break;
			}
			case 1: {
				// 8级神行法宝
				MmochatCommonObject obj = new MmochatSuperMachine(
						MmochatSuperMachineType.神行法宝);
				obj.setCanDeal(true);
				obj.setOverlapNum(1);
				obj
						.setFlyMachineSpeedLevel(MmochatCommonObject.flyMachineMaxSpeedLevel);
				obj
						.setFlyMachineFlyLevel(MmochatCommonObject.flyMachineMaxFlyLevel);
				obj.setFlyMachineCanUseTotalValue(3000);
				obj.setFlyMachineCanUseValue(3000);
				me.addObjectToPackage(obj);

				try {
					MmochatDao.updateRoleAfterAward(me, 0);
				} catch (Exception e) {
					e.printStackTrace();
					me.delRest_award_times(-1);
					me.delPackageObjById(obj.getId());
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}

				String sysInfo = "哇!"
						+ MmochatUtil.wrapColor(me.getName(), Color.green)
						+ "在充值抽奖活动中喜中大奖，得到一个"
						+ MmochatUtil.wrapColor("8级神行法宝(飞行状态)", Color.yellow)
						+ "!朋友们快找他请客呀~";
				sysInfo = MmochatUtil.wrapColor(sysInfo, Color.red);
				MmochatChatService.sendSystemMsg(sysInfo);

				String myInfo = "恭喜恭喜!您喜中大奖，获得一个"
						+ MmochatUtil.wrapColor("8级神行法宝(飞行状态)", Color.yellow)
						+ "，快按3键打开包裹看看吧!";
				CreateTlvWin tlv = getPayAwardTlv(me);
				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				msgbox.setContent(new Text(myInfo));
				msgbox.setLeftName("确定");

				return MmochatUtil.tlvResponse(req.getHallState(),
						new CloseWinTLV(MmochatConstant.TLV_WIN_AWARD), tlv,
						msgbox);
			}
			case 2: {
				// 100000积分
				int addValue = 100000;
				try {
					MmochatDao.updateRoleAfterAward(me, addValue);
				} catch (Exception e) {
					e.printStackTrace();
					me.delRest_award_times(-1);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}
				me.addSuggestScore(addValue);

				String sysInfo = "哇!"
						+ MmochatUtil.wrapColor(me.getName(), Color.green)
						+ "在充值抽奖活动中喜中大奖，得到"
						+ MmochatUtil.wrapColor(addValue + "积分", Color.yellow)
						+ "!朋友们快找他请客呀~";
				sysInfo = MmochatUtil.wrapColor(sysInfo, Color.red);
				MmochatChatService.sendSystemMsg(sysInfo);

				String myInfo = "恭喜恭喜!您喜中大奖，获得"
						+ MmochatUtil.wrapColor(addValue + "积分", Color.yellow)
						+ "!积分可以找推荐使者兑换元宝或K币。";
				CreateTlvWin tlv = getPayAwardTlv(me);
				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				msgbox.setContent(new Text(myInfo));
				msgbox.setLeftName("确定");

				return MmochatUtil.tlvResponse(req.getHallState(),
						new CloseWinTLV(MmochatConstant.TLV_WIN_AWARD), tlv,
						msgbox);
			}
			default:
				break;
			}
		} else {
			// TODO:小奖:道具、首饰、套装材料、金钱、道行
			double rate = Math.random();
			double curRate = 0;

			Object propRate[][] = { { MmochatPropType.急急如律令, 0.01 },
					{ MmochatPropType.天尊令, 0.01 },
					{ MmochatPropType.道尊令, 0.01 },
					{ MmochatPropType.驱兽令, 0.01 },
					{ MmochatPropType.驭兽令, 0.01 },
					{ MmochatPropType.传送符, 0.02 },
					{ MmochatPropType.龙涎香, 0.01 },
					{ MmochatPropType.中血石, 0.01 },
					{ MmochatPropType.大血石, 0.01 },
					{ MmochatPropType.中法池, 0.01 },
					{ MmochatPropType.大法池, 0.01 },
					{ MmochatPropType.中血瓶, 0.01 },
					{ MmochatPropType.大血瓶, 0.01 },
					{ MmochatPropType.中法玲珑, 0.01 },
					{ MmochatPropType.大法玲珑, 0.01 },
					{ MmochatPropType.混沌石, 0.02 },
					{ MmochatPropType.超级改造石, 0.02 },
					{ MmochatPropType.超级白水晶, 0.02 },
					{ MmochatPropType.粉水晶, 0.01 },
					{ MmochatPropType.金水晶, 0.01 },
					{ MmochatPropType.绿水晶, 0.01 },
					{ MmochatPropType.强化水晶, 0.01 },
					{ MmochatPropType.升级石, 0.02 },
					{ MmochatPropType.神行法宝残片, 0.02 },
					{ MmochatPropType.神行法宝灵气丹, 0.01 },
					{ MmochatPropType.神行法宝聚灵丹, 0.01 },
					{ MmochatPropType.神行法宝体力丹, 0.01 },
					{ MmochatPropType.会员周卡, 0.01 },
					{ MmochatPropType.成长丹, 0.02 },
					{ MmochatPropType.超级成长丹, 0.02 },
					{ MmochatPropType.血量成长丹, 0.01 },
					{ MmochatPropType.物攻成长丹, 0.01 },
					{ MmochatPropType.法攻成长丹, 0.01 },
					{ MmochatPropType.速度成长丹, 0.01 },
					{ MmochatPropType.物防成长丹, 0.01 },
					{ MmochatPropType.法防成长丹, 0.01 },
					{ MmochatPropType.轮回水, 0.01 },
					{ MmochatPropType.超级轮回水, 0.01 },
					{ MmochatPropType.迟滞水, 0.01 },
					{ MmochatPropType.八卦令, 0.02 },
					{ MmochatPropType.银联卡, 0.01 },
					{ MmochatPropType.赎罪牌, 0.02 },
					{ MmochatPropType.后悔药, 0.01 },
					{ MmochatPropType.超级后悔药, 0.01 },
					{ MmochatPropType.洗髓丹, 0.02 },
					{ MmochatPropType.江湖名号, 0.01 },
					{ MmochatPropType.超级炼丹剂, 0.02 },
					{ MmochatPropType.照妖镜, 0.01 },
					{ MmochatPropType.女娲石, 0.05 } };

			// 商城道具(另外加上女娲石)
			for (int i = 0; i < propRate.length; i++) {
				curRate += (Double) propRate[i][1];
				if (curRate > rate) {
					// 命中道具
					MmochatProp newProp = new MmochatProp(
							(MmochatPropType) propRate[i][0]);
					me.addObjectToPackage(newProp);

					try {
						MmochatDao.updateRoleAfterAward(me, 0);
					} catch (Exception e) {
						e.printStackTrace();
						me.delRest_award_times(-1);
						me.delPackageObjById(newProp.getId());
						return MmochatUtil.msgbox(req.getHallState(),
								"服务器忙,请稍候再试!");
					}
					// hit = true;
					// break;

					String myInfo = "恭喜恭喜!您获得"
							+ MmochatUtil.wrapColor(newProp.getName(),
									Color.yellow) + "1个，快按3键打开包裹看看吧!";
					CreateTlvWin tlv = getPayAwardTlv(me);
					CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
					msgbox.setContent(new Text(myInfo));
					msgbox.setLeftName("确定");

					return MmochatUtil.tlvResponse(req.getHallState(),
							new CloseWinTLV(MmochatConstant.TLV_WIN_AWARD),
							tlv, msgbox);
				}
			}

			// 首饰
			curRate += 0.05;
			if (curRate > rate) {
				MmochatCommonObject jewelry;
				int type = (int) (Math.random() * 3);
				switch (type) {
				case 0: {
					jewelry = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.挂坠, 0, MmochatEquipQualityType.金装);
					break;
				}
				case 1: {
					jewelry = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.玉佩, 0, MmochatEquipQualityType.金装);
					break;
				}
				case 2: {
					jewelry = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.手镯, 0, MmochatEquipQualityType.金装);
					break;
				}
				default: {
					jewelry = MmochatEquipService.createRandomEquip(true,
							MmochatEquipType.手镯, 0, MmochatEquipQualityType.金装);
				}
				}
				jewelry.setCanDeal(true);
				jewelry.setOverlapNum(1);
				me.addObjectToPackage(jewelry);

				try {
					MmochatDao.updateRoleAfterAward(me, 0);
				} catch (Exception e) {
					e.printStackTrace();
					me.delRest_award_times(-1);
					me.delPackageObjById(jewelry.getId());
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}

				String myInfo = "恭喜恭喜!您获得"
						+ MmochatUtil
								.wrapColor(jewelry.getName(), Color.yellow)
						+ "1个，快按3键打开包裹看看吧!";
				CreateTlvWin tlv = getPayAwardTlv(me);
				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				msgbox.setContent(new Text(myInfo));
				msgbox.setLeftName("确定");

				return MmochatUtil.tlvResponse(req.getHallState(),
						new CloseWinTLV(MmochatConstant.TLV_WIN_AWARD), tlv,
						msgbox);
			}

			// 套装材料
			curRate += 0.1;
			if (curRate > rate) {
				MmochatMaterialType[] materialType = new MmochatMaterialType[] {
						MmochatMaterialType.三级野蛮结晶, MmochatMaterialType.三级智慧结晶,
						MmochatMaterialType.三级活力结晶, MmochatMaterialType.三级灵巧结晶,
						MmochatMaterialType.三级坚韧结晶, MmochatMaterialType.四级野蛮结晶,
						MmochatMaterialType.四级智慧结晶, MmochatMaterialType.四级活力结晶,
						MmochatMaterialType.四级灵巧结晶, MmochatMaterialType.四级坚韧结晶,
						MmochatMaterialType.五级野蛮结晶, MmochatMaterialType.五级智慧结晶,
						MmochatMaterialType.五级活力结晶, MmochatMaterialType.五级灵巧结晶,
						MmochatMaterialType.五级坚韧结晶, MmochatMaterialType.六级野蛮结晶,
						MmochatMaterialType.六级智慧结晶, MmochatMaterialType.六级活力结晶,
						MmochatMaterialType.六级灵巧结晶, MmochatMaterialType.六级坚韧结晶,
						MmochatMaterialType.七级野蛮结晶, MmochatMaterialType.七级智慧结晶,
						MmochatMaterialType.七级活力结晶, MmochatMaterialType.七级灵巧结晶,
						MmochatMaterialType.七级坚韧结晶, MmochatMaterialType.八级野蛮结晶,
						MmochatMaterialType.八级智慧结晶, MmochatMaterialType.八级活力结晶,
						MmochatMaterialType.八级灵巧结晶, MmochatMaterialType.八级坚韧结晶,
						MmochatMaterialType.九级野蛮结晶, MmochatMaterialType.九级智慧结晶,
						MmochatMaterialType.九级活力结晶, MmochatMaterialType.九级灵巧结晶,
						MmochatMaterialType.九级坚韧结晶, MmochatMaterialType.十级野蛮结晶,
						MmochatMaterialType.十级智慧结晶, MmochatMaterialType.十级活力结晶,
						MmochatMaterialType.十级灵巧结晶, MmochatMaterialType.十级坚韧结晶,
						MmochatMaterialType.十一级野蛮结晶,
						MmochatMaterialType.十一级智慧结晶,
						MmochatMaterialType.十一级活力结晶,
						MmochatMaterialType.十一级灵巧结晶,
						MmochatMaterialType.十一级坚韧结晶,
						MmochatMaterialType.十二级野蛮结晶,
						MmochatMaterialType.十二级智慧结晶,
						MmochatMaterialType.十二级活力结晶,
						MmochatMaterialType.十二级灵巧结晶,
						MmochatMaterialType.十二级坚韧结晶 };
				int type = (int) (Math.random() * materialType.length);
				MmochatCommonObject obj = new MmochatMaterial();
				obj.setMaterialType(materialType[type]);
				obj.setCanDeal(true);
				obj.setOverlapNum(20);
				me.addObjectToPackage(obj);

				try {
					MmochatDao.updateRoleAfterAward(me, 0);
				} catch (Exception e) {
					e.printStackTrace();
					me.delRest_award_times(-1);
					me.delPackageObjById(obj.getId());
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}

				String myInfo = "恭喜恭喜!您获得"
						+ MmochatUtil.wrapColor(obj.getName(), Color.yellow)
						+ "20个，快按3键打开包裹看看吧!";
				CreateTlvWin tlv = getPayAwardTlv(me);
				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				msgbox.setContent(new Text(myInfo));
				msgbox.setLeftName("确定");

				return MmochatUtil.tlvResponse(req.getHallState(),
						new CloseWinTLV(MmochatConstant.TLV_WIN_AWARD), tlv,
						msgbox);
			}

			// 道行365天
			curRate += 0.05;
			if (curRate > rate) {
				// 刷道比赛
				MmochatPropService.dealDaoActivity(me, 365);

				int trueDao = MmochatBattleService.getRealDao(me, 365);
				me.addDao(trueDao);

				try {
					MmochatDao.updateRoleAfterAward(me, 0);
				} catch (Exception e) {
					e.printStackTrace();
					me.delRest_award_times(-1);
					me.addDao(-trueDao);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}

				String myInfo = "恭喜恭喜!您获得道行"
						+ MmochatUtil.wrapColor(trueDao, Color.yellow) + "天!";
				CreateTlvWin tlv = getPayAwardTlv(me);
				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				msgbox.setContent(new Text(myInfo));
				msgbox.setLeftName("确定");

				return MmochatUtil.tlvResponse(req.getHallState(),
						new CloseWinTLV(MmochatConstant.TLV_WIN_AWARD), tlv,
						msgbox);
			}

			// 游戏币10W
			{
				int addSmallMoney = 100000;
				me.addAndUpdateSmall_money(addSmallMoney);

				try {
					MmochatDao.updateRoleAfterAward(me, 0);
				} catch (Exception e) {
					e.printStackTrace();
					me.delRest_award_times(-1);
					me.addAndUpdateSmall_money(-addSmallMoney);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}

				String myInfo = "恭喜恭喜!您获得金钱"
						+ MmochatUtil.wrapColor(addSmallMoney, Color.yellow)
						+ "文!";
				CreateTlvWin tlv = getPayAwardTlv(me);
				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				msgbox.setContent(new Text(myInfo));
				msgbox.setLeftName("确定");

				return MmochatUtil.tlvResponse(req.getHallState(),
						new CloseWinTLV(MmochatConstant.TLV_WIN_AWARD), tlv,
						msgbox);
			}

		}
		return null;
	}

	// 临时活动：充值排名抽奖
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_21(SkymobiHandler handler,
			Mmochat_13_21C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		MmochatRolePayInfo myInfo = null;
		int index = 1;
		for (MmochatRolePayInfo info : MmochatTempActivityService.payRank) {
			if (info.getRoleId() == me.getRoleId()) {
				myInfo = info;
				break;
			}
			index++;
		}
		if (myInfo == null) {
			return MmochatUtil.msgbox(req.getHallState(), "您未上充值前十名，无法进行抽奖!");
		}
		if (myInfo.getAwardTimes() <= 0) {
			return MmochatUtil.msgbox(req.getHallState(), "您的抽奖次数已用光!");
		}
		if (me.isPetFull()) {
			return MmochatUtil.msgbox(req.getHallState(),
					"您携带的宠物数量已达上限，请先存放部分宠物到仓库，再进行抽奖!");
		}
		if (!me.hasEnoughPackageSpace(1)) {
			return MmochatUtil.msgbox(req.getHallState(),
					"您的包裹已满，请先至少清理出一个空位，再进行抽奖!");
		}
		synchronized (myInfo) {
			if (myInfo.getAwardTimes() <= 0) {
				return MmochatUtil.msgbox(req.getHallState(), "您的抽奖次数已用光!");
			}
			myInfo.delAwardTimes(1);
		}
		// 开始抽奖
		// 17%机率中大奖，没中大奖就获得其它奖励
		if (index == 1) {
			// 第1名，必中神兽
			MmochatRoleType[] list = new MmochatRoleType[] {
					MmochatRoleType.高力玄武, MmochatRoleType.通灵玄武,
					MmochatRoleType.铁血玄武, MmochatRoleType.幻影玄武 };
			int itemIndex = MmochatUtil.getRandomValue(list.length);
			MmochatRoleType type = list[itemIndex];
			MmochatPet pet = MmochatPetService.createPetByType(type);
			if (pet != null) {
				me.addPet(pet);
				try {
					MmochatDao.updateRolePets(me);
				} catch (Exception e) {
					e.printStackTrace();
				}

				Mmochat_5_10S pack = new Mmochat_5_10S();
				pack.addPet(pet);
				MmochatUtil.sendCommonPack(me, pack);

				String sysInfo = MmochatUtil.wrapColor(me.getName(),
						Color.green)
						+ "在充值排行送神兽活动中喜中大奖，得到一个"
						+ MmochatUtil.wrapColor(pet.getPetTypeName(),
								Color.yellow) + "!朋友们快找他请客呀~";
				sysInfo = MmochatUtil.wrapColor(sysInfo, Color.red);
				MmochatChatService.sendSystemMsg(sysInfo);

				String myInfo1 = "恭喜恭喜!您喜中大奖，获得一个"
						+ MmochatUtil.wrapColor(pet.getPetTypeName(),
								Color.yellow) + "，快按0键打开宠物信息看看吧!";
				myInfo1 = MmochatUtil.wrapColor(myInfo1, Color.red);
				MmochatChatService.sendSystemMsgToPerson(me, myInfo1);
				return MmochatUtil.msgbox(req.getHallState(), myInfo1);
			}
		} else if (MmochatUtil.isInPercent(17)) {
			// 大奖:神兽、变异、法宝
			int awardIndex = (int) (Math.random() * 3);
			switch (awardIndex) {
			case 0: {
				MmochatRoleType[] list = new MmochatRoleType[] {
						MmochatRoleType.高力玄武, MmochatRoleType.通灵玄武,
						MmochatRoleType.铁血玄武, MmochatRoleType.幻影玄武 };
				int itemIndex = MmochatUtil.getRandomValue(list.length);
				MmochatRoleType type = list[itemIndex];
				MmochatPet pet = MmochatPetService.createPetByType(type);
				if (pet != null) {
					me.addPet(pet);
					try {
						MmochatDao.updateRolePets(me);
					} catch (Exception e) {
						e.printStackTrace();
					}

					Mmochat_5_10S pack = new Mmochat_5_10S();
					pack.addPet(pet);
					MmochatUtil.sendCommonPack(me, pack);

					String sysInfo = MmochatUtil.wrapColor(me.getName(),
							Color.green)
							+ "在充值排行送神兽活动中喜中大奖，得到一个"
							+ MmochatUtil.wrapColor(pet.getPetTypeName(),
									Color.yellow) + "!朋友们快找他请客呀~";
					sysInfo = MmochatUtil.wrapColor(sysInfo, Color.red);
					MmochatChatService.sendSystemMsg(sysInfo);

					String myInfo1 = "恭喜恭喜!您喜中大奖，获得一个"
							+ MmochatUtil.wrapColor(pet.getPetTypeName(),
									Color.yellow) + "，快按0键打开宠物信息看看吧!";
					myInfo1 = MmochatUtil.wrapColor(myInfo1, Color.red);
					MmochatChatService.sendSystemMsgToPerson(me, myInfo1);
					return MmochatUtil.msgbox(req.getHallState(), myInfo1);
				}
				break;
			}
			case 1: {
				// 8级神行法宝
				MmochatCommonObject obj = new MmochatSuperMachine(
						MmochatSuperMachineType.神行法宝);
				obj.setCanDeal(true);
				obj.setOverlapNum(1);
				obj
						.setFlyMachineSpeedLevel(MmochatCommonObject.flyMachineMaxSpeedLevel);
				obj
						.setFlyMachineFlyLevel(MmochatCommonObject.flyMachineMaxFlyLevel);
				obj.setFlyMachineCanUseTotalValue(3000);
				obj.setFlyMachineCanUseValue(3000);
				me.addObjectToPackage(obj);

				try {
					MmochatDao.updateMyPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
				}

				String sysInfo = MmochatUtil.wrapColor(me.getName(),
						Color.green)
						+ "在充值排行送神兽活动中喜中大奖，得到一个"
						+ MmochatUtil.wrapColor("8级神行法宝(飞行状态)", Color.yellow)
						+ "!朋友们快找他请客呀~";
				sysInfo = MmochatUtil.wrapColor(sysInfo, Color.red);
				MmochatChatService.sendSystemMsg(sysInfo);

				String myInfo1 = "恭喜恭喜!您喜中大奖，获得一个"
						+ MmochatUtil.wrapColor("8级神行法宝(飞行状态)", Color.yellow)
						+ "，快按3键打开包裹看看吧!";
				myInfo1 = MmochatUtil.wrapColor(myInfo1, Color.red);
				MmochatChatService.sendSystemMsgToPerson(me, myInfo1);
				return MmochatUtil.msgbox(req.getHallState(), myInfo1);
			}
			case 2: {
				MmochatRoleType type = MmochatRoleType.小龙人;
				MmochatPet pet = MmochatPetService.createPetByType(type);
				if (pet != null) {
					me.addPet(pet);
					try {
						MmochatDao.updateRolePets(me);
					} catch (Exception e) {
						e.printStackTrace();
					}

					Mmochat_5_10S pack = new Mmochat_5_10S();
					pack.addPet(pet);
					MmochatUtil.sendCommonPack(me, pack);

					String sysInfo = MmochatUtil.wrapColor(me.getName(),
							Color.green)
							+ "在充值排行送神兽活动中喜中大奖，得到一个"
							+ MmochatUtil.wrapColor(pet.getPetTypeName(),
									Color.yellow) + "!朋友们快找他请客呀~";
					sysInfo = MmochatUtil.wrapColor(sysInfo, Color.red);
					MmochatChatService.sendSystemMsg(sysInfo);

					String myInfo1 = "恭喜恭喜!您喜中大奖，获得一个"
							+ MmochatUtil.wrapColor(pet.getPetTypeName(),
									Color.yellow) + "，快按0键打开宠物信息看看吧!";
					myInfo1 = MmochatUtil.wrapColor(myInfo1, Color.red);
					MmochatChatService.sendSystemMsgToPerson(me, myInfo1);
					return MmochatUtil.msgbox(req.getHallState(), myInfo1);
				}
				break;
			}
			default:
				break;
			}
		} else {
			// 小奖:1个年兽蛋+道行+战绩+游戏币
			MmochatProp prop = new MmochatProp(MmochatPropType.年兽蛋);
			me.addObjectToPackage(prop);

			int daoAward = MmochatUtil.getRandomValue(182, 546);
			// 刷道比赛
			MmochatPropService.dealDaoActivity(me, daoAward);

			me.addDao(daoAward);

			int zhanJi = MmochatUtil.getRandomValue(500, 1500);
			me.addZhanji(zhanJi);

			int addMoney = MmochatUtil.getRandomValue(100000, 300000);
			me.addSmall_money(addMoney);

			try {
				MmochatDao.savePackageDaoZhanJiSmallMoney(me, addMoney);
			} catch (Exception e) {
				e.printStackTrace();
			}

			String myInfo1 = "很遗憾，您没有抽中大奖!您获得了"
					+ MmochatUtil.wrapColor("1个年兽蛋、" + daoAward + "天道行、"
							+ zhanJi + "点战绩、"
							+ MmochatUtil.getColorMoney(addMoney) + "文钱",
							Color.yellow) + "!";
			MmochatChatService.sendSystemMsgToPerson(me, myInfo1);
			return MmochatUtil.msgbox(req.getHallState(), myInfo1);
		}
		return null;
	}

	// 使用道具变更门派
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_22(SkymobiHandler handler,
			Mmochat_13_22C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		// 判断地图，不能在本门派地图、门派房间内使用此道具
		int[] forbidmapId = new int[] { 42, 45, 46, 47, 43, 48, 49, 50, 44, 51,
				52, 53 };
		for (int mapId : forbidmapId) {
			if (me.getMapId() == mapId) {
				return MmochatUtil
						.msgbox(req.getHallState(), "不能在本门派地图中使用此道具!");
			}
		}

		MmochatFamilyType oldFamily = me.getFamily();

		MmochatFamilyType family = MmochatFamilyType.get(req.getFamilyValue());
		if (family == null) {
			return MmochatUtil.msgbox(req.getHallState(), "此门派不存在!");
		}

		// 检查新的门派是否与现在的门派相同
		if (me.getFamily().getValue() == req.getFamilyValue()) {
			return MmochatUtil.msgbox(req.getHallState(), "必需选择不同的门派加入!");
		}

		MmochatRoleType oldRoleType = me.getRoleType();
		MmochatRoleType newRoleType = null;
		if (me.getSexual() == 0 && req.getFamilyValue() == 0) {
			newRoleType = MmochatRoleType.阐教男;
		} else if (me.getSexual() == 1 && req.getFamilyValue() == 0) {
			newRoleType = MmochatRoleType.阐教女;
		} else if (me.getSexual() == 0 && req.getFamilyValue() == 1) {
			newRoleType = MmochatRoleType.人教男;
		} else if (me.getSexual() == 1 && req.getFamilyValue() == 1) {
			newRoleType = MmochatRoleType.人教女;
		} else if (me.getSexual() == 0 && req.getFamilyValue() == 2) {
			newRoleType = MmochatRoleType.截教男;
		} else if (me.getSexual() == 1 && req.getFamilyValue() == 2) {
			newRoleType = MmochatRoleType.截教女;
		}

		MmochatPackageGrid grid;
		MmochatCommonObject prop;

		synchronized (me) {
			grid = me.getMyPackage().get(req.getGridId());
			if (grid == null) {
				return MmochatUtil.msgbox(req.getHallState(), "您没有脱胎换骨水，请先购买!");
			}
			prop = grid.getObject();
			if (prop == null || prop.getPropType() != MmochatPropType.脱胎换骨水
					|| prop.isUsedOut()) {
				return MmochatUtil.msgbox(req.getHallState(), "您没有脱胎换骨水，请先购买!");
			}

			// 消耗脱胎换骨水
			prop.use(1);
			if (prop.isUsedOut()) {
				grid.setObject(null);
			}
			MmochatStatisticsService.addPropCost(MmochatPropType.脱胎换骨水, 1);

			// 清除门派技能，变更：roleType，family
			me.getSkills().clear();
			me.setFamily(family);
			me.setRoleType(newRoleType);

			// 清除门派试炼任务
			try {
				MmochatTask myTask = me.getTaskByType(MmochatTaskType.门派试炼);
				if (myTask != null) {
					me.getTasks().remove(myTask.getTaskId());
					// 下发删除任务
					Mmochat_4_12S taskPack = new Mmochat_4_12S();
					taskPack.setTaskId(myTask.getTaskId());
					MmochatUtil.sendCommonPack(me, taskPack);
				}
			} catch (Exception e1) {
				e1.printStackTrace();
			}

			// 保存数据库:包裹、门派、技能、图片
			try {
				MmochatDao.changeFamily(me);
			} catch (Exception e) {
				e.printStackTrace();
				prop.addOverlapNum(1);
				grid.setObject(prop);
				me.setFamily(oldFamily);
				me.setRoleType(oldRoleType);
				return MmochatUtil.msgbox(req.getHallState(),
						"服务器忙，请稍候再试!您的技能目前已被清空!");
			}
		}

		// 下发更新包裹
		Mmochat_5_1S pack = new Mmochat_5_1S();
		pack.addGrid(grid);
		MmochatUtil.sendCommonPack(me, pack);

		// 下发通知消息:退出游戏重新进入才能生效
		String sysInfo = MmochatUtil.wrapColor(me.getName(), Color.green)
				+ "使用了" + MmochatPropType.脱胎换骨水.toString() + "，改换门庭，加入了"
				+ MmochatUtil.wrapColor(family.getName(), Color.yellow) + "!";
		MmochatChatService.sendSystemMsg(sysInfo);
		return MmochatUtil.msgbox(req.getHallState(), "您使用脱胎换骨水，成功加入了"
				+ MmochatUtil.wrapColor(family.getName(), Color.yellow) + "!"
				+ MmochatUtil.wrapColor("请退出游戏重新进入，完成本次门派变更!", Color.red));
	}

	// 首次充值活动是否满足条件
	public static boolean canTakeFirstPayAward(MmochatPlayer me) {
		if (me.getLatest_pay_time() == 0
				&& MmochatSystemState.isFirstPay_open()
				&& me.getLevel() >= MmochatSystemState.getFirstPay_minLevel()) {
			return true;
		}
		return false;
	}

	// 保存数据库放在保存充值时一起操作
	public static void setFirstPayAward(MmochatPlayer me) {
		if (canTakeFirstPayAward(me)) {
			// 首次充值、活动期间、等级达标
			String awardInfo = "恭喜您获得首次充值豪礼：";
			// 道行奖励
			int totalDao = 0;
			for (int i = 0; i < MmochatSystemState.getFirstPay_daoAward(); i++) {
				// 刷道比赛
				MmochatPropService.dealDaoActivity(me, 365);
				int trueDao = MmochatBattleService.getRealDao(me, 365);
				me.addDao(trueDao);
				totalDao += trueDao;
			}
			awardInfo += "\n"
					+ MmochatUtil.wrapColor(totalDao + "天道行!", Color.red);

			// 经验奖励
			int expTimes = MmochatSystemState.getFirstPay_expAward();
			Map<MmochatRoleAttributeType, Double> attrMap = MmochatPetService.monsterBaseAttackData
					.get(me.getTrueLevel());
			if (attrMap != null) {
				int expAward = (int) (attrMap
						.get(MmochatRoleAttributeType.杀死怪物经验) * expTimes);
				me.addExp(expAward);
				awardInfo += "\n"
						+ MmochatUtil.wrapColor(expAward + "点经验!", Color.red);
			}

			awardInfo = MmochatUtil.wrapColor(awardInfo, Color.yellow);
			MmochatFriendService.sendMsgToPersonByFriendMessage(me, awardInfo);
			MmochatChatService.sendSystemMsgToPerson(me, awardInfo);
			firstPayAwardCount++;
		}
	}

	@SuppressWarnings("deprecation")
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_24(SkymobiHandler handler,
			Mmochat_13_24C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		switch (req.getIndex()) {
		case 2: {
			// 线下出售角色
			Date now = new Date();
			int weekday = now.getDay();// 0 = Sunday, 1 = Monday, 2 = Tuesday, 3
			// = Wednesday, 4 = Thursday, 5 =
			// Friday, 6 = Saturday
			int hour = now.getHours();// 0-23
			// if (weekday == 6 || weekday == 0) {
			// return MmochatUtil.msgbox(req.getHallState(),
			// "线下业务周末不受理!受理时间：周一至周五,10:00-18:00");
			// }
			// if (hour < 10 || hour > 17) {
			// return MmochatUtil.msgbox(req.getHallState(),
			// "线下业务受理时间：周一至周五,10:00-18:00!现在不是受理时间!");
			// }
			if (weekday == 4 && hour > 11 && hour < 16) {
				return MmochatUtil.msgbox(req.getHallState(),
						"每周四下午例行维护，故12点至16点期间不能提交售号请求!");
			}
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setLeftName("出售");
			tlv.setRightName("返回");
			tlv.setTitle("我要出售角色");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());
			String content = "";
			content += MmochatUtil.wrapColor("[出售流程]\n", Color.yellow);
			content += "1、请先联系好买家，谈好售价，并记下买家的角色ID。价格允许为0元。\n\n";
			content += "2、"
					+ MmochatUtil.wrapColor("重新创建一个0级角色", Color.red)
					+ "，然后在本页面按左按钮<出售>键，然后根据提示输入相关信息。"
					+ MmochatUtil.wrapColor("如果价格为0元，则无须输入买家，角色会直接转移到当前冒泡账号下!",
							Color.magenta) + "\n\n";
			content += MmochatUtil.wrapColor("[售号条件]\n", Color.yellow);
			content += "角色在30天内的交易，必须是通过同一部手机进行的才能出售。"
					+ "并同意最后交易金额以手机充值卡的方式充值成手机话费。官方不收取费用。\n";
			content += MmochatUtil.wrapColor("[安全问题]\n", Color.yellow);
			content += "官方线下交易流程保证交易安全，不通过本流程进行的私下交易造成的损失无法追回，"
					+ "且私自交易官方不予承认。出售的角色会转移到买家的冒泡账号下。客服负责判定买家提供的"
					+ "充值卡是否有效。客服电话：0571-85222407";
			tlv.setContent(new Text(content));

			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_20_1, (int) me
							.getRoleId()));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(true);
			tlv.addLeftTLV(wait);
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 3: {
			// 我的角色订单
			List<MmochatRoleDeal> myOrders = new ArrayList<MmochatRoleDeal>();
			for (MmochatRoleDeal deal : MmochatGmService.roleDeals.values()) {
				if (deal.getState() == MmochatRoleDealState.创建中) {
					continue;
				}
				if (deal.getSellerId() == me.getRoleId()
						|| deal.getBuyerId() == me.getRoleId()) {
					myOrders.add(deal);
				}
			}
			if (myOrders.size() == 0) {
				return MmochatUtil.msgbox(req.getHallState(), "目前没有您的角色交易订单!");
			}
			Collections.sort(myOrders);
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("查看");
			tlv.setRightName("返回");
			tlv.setTitle("我的角色订单");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());

			for (MmochatRoleDeal deal : myOrders) {
				if (deal.getSellerId() == me.getRoleId()) {
					// 出售
					String item = "[出售]" + deal.getSellRoleName() + "\n";
					item += MmochatUtil.wrapColor("进度:"
							+ deal.getState().getInfo(), Color.magenta)
							+ "\n";
					item += "订单号:" + deal.getId();
					tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
							(int) deal.getId()));
				} else if (deal.getBuyerId() == me.getRoleId()) {
					// 求购
					String item = "[求购]" + deal.getSellRoleName() + "\n";
					item += MmochatUtil.wrapColor("进度:"
							+ deal.getState().getInfo(), Color.magenta)
							+ "\n";
					item += "订单号:" + deal.getId();
					tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
							(int) deal.getId()));
				}
			}

			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_20_9, (int) me
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 4: {
			// 线下出售财物
			Date now = new Date();
			int weekday = now.getDay();// 0 = Sunday, 1 = Monday, 2 = Tuesday, 3
			// = Wednesday, 4 = Thursday, 5 =
			// Friday, 6 = Saturday
			int hour = now.getHours();// 0-23
			if (weekday == 6 || weekday == 0) {
				return MmochatUtil.msgbox(req.getHallState(),
						"线下财物业务周末不受理!受理时间：周一至周五,10:00-18:00");
			}
			if (hour < 10 || hour > 17) {
				return MmochatUtil.msgbox(req.getHallState(),
						"线下财物业务受理时间：周一至周五,10:00-18:00!现在不是受理时间!");
			}
			if (weekday == 4 && hour > 11 && hour < 16) {
				return MmochatUtil.msgbox(req.getHallState(),
						"每周四下午例行维护，故12点至16点期间不能提交出售请求!");
			}
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setLeftName("发送");
			tlv.setRightName("返回");
			tlv.setTitle("线下出售财物");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());
			String content = "";
			content += MmochatUtil.wrapColor("[出售条件]\n", Color.yellow);
			content += "角色在30天内的交易，必须是通过同一部手机进行的才能出售财物，支持装备、法宝、道具、金钱、宠物等。\n";
			content += MmochatUtil.wrapColor("[出售流程]\n", Color.yellow);
			content += "1、请先联系好买家，谈好售价。\n";
			content += "2、" + MmochatUtil.wrapColor("重新创建一个0级角色", Color.red)
					+ "，用此角色在此页面，按左按钮<发送>键，发送以下格式内容:\n";
			content += MmochatUtil
					.wrapColor(
							"财物所在角色ID:xx，所在角色钱庄密码:xx，买家角色ID:xx，售价:xx元，我的手机号:xx，财物描述:xx\n",
							Color.magenta);
			content += "3、将包裹第一页清空，要出售的物品放到包裹第一页。"
					+ "通知买家在游戏中保持在线，然后打客服电话:0571-85222407通知客服具体交易物品信息并进行受理。\n\n";
			content += MmochatUtil.wrapColor("[安全问题]\n", Color.yellow);
			content += "官方线下交易流程保证交易安全，不通过本流程进行的私下交易造成的损失无法追回，"
					+ "且私自交易官方不予承认。客服负责判定买家提供的充值卡是否有效。\n\n";
			tlv.setContent(new Text(content));

			CreateEditBoxTLV edit = new CreateEditBoxTLV();
			edit
					.setTitle("请严格按以下格式发送:\n"
							+ "财物所在角色ID:xx，所在角色钱庄密码:xx，买家角色ID:xx，售价:xx元，我的手机号:xx，财物描述:xx\n");
			edit.setLeftName("发送");
			edit.setRightName("取消");
			edit.setContentLenMax(255);
			edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
			edit.setInputType(CreateEditBoxTLV.INPUT_ANY << 4);
			edit.addLeftTLV(new ClearDataTLV());
			edit.addLeftTLV(new AddDataTLV((int) 2));
			edit.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
			edit.addLeftTLV(new AddEditBoxTLV());
			edit.addLeftTLV(new SendDataTLV(
					MmochatConstant.getClientModuleId(), MmochatMain
							.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_11_6, null));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(false);
			edit.addLeftTLV(wait);
			tlv.addLeftTLV(edit);
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 5: {
			return MmochatUtil.msgbox(req.getHallState(), "转号流程：请点击<"
					+ MmochatUtil.wrapColor("我要出售角色", Color.yellow)
					+ ">，然后出售价格填写为0元，即可自助转号!");
		}
		default:
			break;
		}
		return MmochatUtil.msgbox(req.getHallState(), "暂无此功能!");
	}

	@SkymobiService
	public SkymobiProtocolMessage handleC_13_25(SkymobiHandler handler,
			Mmochat_13_25C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		int borrowerId;
		try {
			int tmp = Integer.parseInt(req.getEdit(), 16);
			borrowerId = tmp / 3;
			if (borrowerId * 3 != tmp) {
				return MmochatUtil.msgbox(req.getHallState(), "您输入的角色ID不正确!");
			}
		} catch (NumberFormatException e) {
			return MmochatUtil.msgbox(req.getHallState(),
					"您输入的角色ID不正确!角色ID示例：34af1，字母大小写任意。");
		}
		if (me.getRoleId() == borrowerId) {
			return MmochatUtil.msgbox(req.getHallState(), "请填写借您财物的玩家的角色ID!");
		}
		if (me.getSmall_money() < MmochatConstant.moneyNeedForGetBackBorrowed) {
			return MmochatUtil.msgbox(req.getHallState(), "自助找回需要"
					+ MmochatConstant.moneyNeedForGetBackBorrowed
					+ "文钱，您包裹里的金钱不足!");
		}

		int packNum = me.getPackageSpaceNum();

		MmochatPlayer he = MmochatGmService.getRoleInfoById(borrowerId);
		if (he == null) {
			return MmochatUtil.msgbox(req.getHallState(), "您输入的角色ID不正确!角色不存在!");
		}

		if (he.isInBattle()) {
			return MmochatUtil.msgbox(req.getHallState(), "对方当前正在战斗中，请稍候再试!");
		}

		String msg;
		String hisMsg;
		synchronized (me) {
			// 扣钱
			me.addAndUpdateSmall_money(-1
					* MmochatConstant.moneyNeedForGetBackBorrowed);
			try {
				MmochatDao.updateRoleSmallMoney(me);
			} catch (Exception e) {
				e.printStackTrace();
				me
						.addAndUpdateSmall_money(MmochatConstant.moneyNeedForGetBackBorrowed);
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
			}
			msg = "";
			hisMsg = "";
			// 找回宠物
			boolean hasPet = false;
			List<MmochatPet> petList = new ArrayList<MmochatPet>();
			List<MmochatPet> storePetList = new ArrayList<MmochatPet>();
			for (MmochatPet pet : he.getPets().values()) {
				if (pet != null && pet.getBorrowFromRoleId() != null
						&& pet.getBorrowFromRoleId() == me.getRoleId()) {
					petList.add(pet);
					he.getPets().remove(pet.getId());
					pet.setBorrowFromRoleId(null);
					pet.setState(MmochatPetStateType.休息);
					me.getStoredPets().put(pet.getId(), pet);
					hasPet = true;
				}
			}
			for (MmochatPet pet : he.getStoredPets().values()) {
				if (pet != null && pet.getBorrowFromRoleId() != null
						&& pet.getBorrowFromRoleId() == me.getRoleId()) {
					storePetList.add(pet);
					he.getStoredPets().remove(pet.getId());
					pet.setBorrowFromRoleId(null);
					pet.setState(MmochatPetStateType.休息);
					me.getStoredPets().put(pet.getId(), pet);
					hasPet = true;
				}
			}
			if (hasPet) {
				try {
					MmochatDao.getBorrowedPetBack(me, he);
				} catch (Exception e) {
					e.printStackTrace();
					for (MmochatPet pet : petList) {
						pet.setBorrowFromRoleId(me.getRoleId());
						he.addPet(pet);
						me.getStoredPets().remove(pet.getId());
					}
					for (MmochatPet pet : storePetList) {
						pet.setBorrowFromRoleId(me.getRoleId());
						he.getStoredPets().put(pet.getId(), pet);
						me.getStoredPets().remove(pet.getId());
					}
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}
				msg += "您借出的宠物已经找回，请到" + MmochatUtil.wrapColor("钱庄", Color.red)
						+ "领取!\n";
				hisMsg += "您向"
						+ MmochatUtil.wrapColor(me.getName(), Color.green)
						+ "借的宠物已经被对方找回!\n";
			}
			// 包裹找回物品
			boolean updatePackage = false;
			String tail = "";
			List<MmochatCommonObject> objList = new ArrayList<MmochatCommonObject>();
			List<MmochatCommonObject> storeObjList = new ArrayList<MmochatCommonObject>();
			if (packNum > 0) {
				for (MmochatPackageGrid grid : he.getMyPackage().values()) {
					if (grid != null) {
						MmochatCommonObject obj = grid.getObject();
						if (obj != null && obj.getBorrowFromRoleId() != null
								&& obj.getBorrowFromRoleId() == me.getRoleId()) {
							updatePackage = true;
							objList.add(obj);
							if (grid.getGridType() == MmochatPackageGridType.身上装备格子) {
								// 先卸下
								// 判断卸下之前是否是一身套装
								boolean isSet = he
										.isAllWeaponedEquipTheSameSet();
								// 更新装备使用者
								grid.getObject().setEquipUserRoleId(null);
								grid.setObject(null);
								// 下发更新包裹数据
								Mmochat_5_1S pack = new Mmochat_5_1S();
								if (isSet) {
									// 如果是套装，需要更新4件套装备和套装效果
									MmochatPackageGrid grid1 = he
											.getMyPackage().get(
													MmochatEquipPlaceType.头部
															.getValue());
									if (grid1 != null) {
										pack.addGrid(grid1);
									}
									grid1 = he.getMyPackage()
											.get(
													MmochatEquipPlaceType.手上
															.getValue());
									if (grid1 != null) {
										pack.addGrid(grid1);
									}
									grid1 = he.getMyPackage()
											.get(
													MmochatEquipPlaceType.身体
															.getValue());
									if (grid1 != null) {
										pack.addGrid(grid1);
									}
									grid1 = he.getMyPackage().get(
											MmochatEquipPlaceType.脚.getValue());
									if (grid1 != null) {
										pack.addGrid(grid1);
									}

									// 更新套装效果
									Mmochat_1_16S effect = new Mmochat_1_16S();
									effect.setMe(he);
									MmochatUtil.sendCommonPack(he, effect);
								}
								pack.addGrid(grid);
								MmochatUtil.sendCommonPack(he, pack);
							} else {
								grid.setObject(null);
								// 下发更新包裹数据
								Mmochat_5_1S pack = new Mmochat_5_1S();
								pack.addGrid(grid);
								MmochatUtil.sendCommonPack(he, pack);
							}
							obj.setBorrowFromRoleId(null);
							me.addObjectToPackage(obj);
							packNum = me.getPackageSpaceNum();
							if (packNum <= 0) {
								tail = "您的包裹已满，如果还有未找回物品，请清理出空位后继续找回。";
								break;
							}
						}
					}
				}
			}
			// 钱庄找回
			if (packNum > 0) {
				for (MmochatPackageGrid grid : he.getMyStorage().values()) {
					if (grid != null) {
						MmochatCommonObject obj = grid.getObject();
						if (obj != null && obj.getBorrowFromRoleId() != null
								&& obj.getBorrowFromRoleId() == me.getRoleId()) {
							updatePackage = true;
							storeObjList.add(obj);

							grid.setObject(null);
							obj.setBorrowFromRoleId(null);
							me.addObjectToPackage(obj);
							packNum = me.getPackageSpaceNum();
							if (packNum <= 0) {
								tail = "您的包裹已满，如果还有未找回物品，请清理出空位后继续找回。";
								break;
							}
						}
					}
				}
			}
			if (updatePackage) {
				try {
					MmochatDao.getBorrowedObjBack(me, he);
				} catch (Exception e) {
					e.printStackTrace();
					for (MmochatCommonObject obj : objList) {
						obj.setBorrowFromRoleId(me.getRoleId());
						boolean ret = he.addObjectToPackage(obj);
						if (!ret) {
							he.addObjectToStorage(obj);
						}
						me.delPackageObjById(obj.getId());
					}
					for (MmochatCommonObject obj : storeObjList) {
						obj.setBorrowFromRoleId(me.getRoleId());
						he.addObjectToStorage(obj);
						me.delPackageObjById(obj.getId());
					}
					return MmochatUtil.msgbox(req.getHallState(), msg
							+ "\n服务器忙,请稍候再试!");
				}
				// 更新人物状态
				Mmochat_1_16S pack = new Mmochat_1_16S();
				pack.setMe(he);
				MmochatUtil.sendCommonPack(he, pack);

				msg += "您借出的物品已经找回到您的" + MmochatUtil.wrapColor("包裹", Color.red)
						+ "!" + tail;
				hisMsg += "您向"
						+ MmochatUtil.wrapColor(me.getName(), Color.green)
						+ "借的物品已经被对方找回!\n";
			}
			if (!updatePackage && !hasPet) {
				if (packNum == 0) {
					return MmochatUtil.msgbox(req.getHallState(),
							"您的包裹已满，请先清理出一定的空位!");
				}
				return MmochatUtil.msgbox(req.getHallState(),
						"您没有借过东西给对方!(交易中对方给出借条，才能自助找回)");
			}
		}
		MmochatGmService.sendKufuPrivateMsg(he.getRoleId(), hisMsg, false);
		MmochatGmService.sendKufuPrivateMsg(me.getRoleId(), msg, false);
		MmochatChatService.sendSystemMsgToPerson(me, msg);
		return MmochatUtil.msgbox(req.getHallState(), msg);
	}

	// 查看刷道比赛
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_26(SkymobiHandler handler,
			Mmochat_13_26C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (daoActivityInfo == null
				|| daoActivityInfo.getState() == MmochatPayLotteryState.活动结束) {
			return MmochatUtil.msgbox(req.getHallState(), "刷道比赛已结束或未开始!");
		}
		switch (req.getIndex()) {
		case 1: {
			// 活动说明
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle("刷道比赛");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());
			String content = MmochatUtil.wrapColor("[活动说明]\n", Color.yellow);
			content += daoActivityInfo.getInfo() + "\n\n";
			content += MmochatUtil.wrapColor("[道行统计]\n", Color.yellow);
			content += "在活动期间，通过各种活动获得的道行，以削减前的道行值来统计。"
					+ "对活动期间累积获得的道行值进行排名，并进行相应奖励发放。\n\n";
			content += MmochatUtil.wrapColor("[奖励发放]\n", Color.yellow);
			content += "奖励类别如果是游戏币、元宝、经验、道行等数值奖励，则奖励会在活动结束时直接发放到用户"
					+ "角色上；如果是K币或人民币奖励，则奖励会在7个工作日内进行发放。";
			tlv.setContent(new Text(content));
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 2: {
			// 当前排名
			List<MmochatDaoRole> top = daoActivityInfo.getTop();

			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setRightName("返回");
			tlv.setTitle("当前刷道排名");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());

			int myDao = daoActivityInfo.getMyDao(me);
			String item = MmochatUtil.wrapColor("我的刷道信息\n", Color.yellow);
			item += "累积:" + myDao + "天";
			tlv.addItemEvent(item);

			int index = 1;
			for (MmochatDaoRole info : top) {
				item = MmochatUtil.wrapColor("第" + index + "名:"
						+ info.getName() + "\n", Color.magenta);
				item += "ID:" + Integer.toHexString((3 * info.getRoleId()))
						+ "\n";
				item += "累积:" + info.getDao() + "天";
				tlv.addItemEvent(item);
				index++;
			}
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 3: {
			// 活动奖励
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle("活动奖励");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());
			String content = MmochatUtil.wrapColor("[活动奖励]\n", Color.yellow);
			int index = 1;
			for (Integer num : daoActivityInfo.getMoneyAwards()) {
				content += "第" + index + "名:" + num
						+ daoActivityInfo.getMoneyType().toString() + "\n";
				index++;
			}
			tlv.setContent(new Text(content));
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		default:
			break;
		}
		return MmochatUtil.msgbox(req.getHallState(), "暂无此功能!");
	}

	// 即时充值抽奖
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_27(SkymobiHandler handler,
			Mmochat_13_27C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (fastPayLotteryInfo == null
				|| fastPayLotteryInfo.getState() != MmochatPayLotteryState.开始统计) {
			return MmochatUtil.msgbox(req.getHallState(), "本活动已经结束，无法抽奖!");
		}
		String userInfo = "";
		synchronized (me) {
			MmochatFastLotteryRole myInfo = fastPayLotteryInfo.getPayRoles()
					.get(me.getRoleId());
			if (myInfo == null || myInfo.getAwardTimes() <= 0) {
				return MmochatUtil.msgbox(req.getHallState(), "您还没有抽奖机会!只要充值"
						+ (fastPayLotteryInfo.getMoneyNeed() / 100) + "元即可抽奖。");
			}
			if (fastPayLotteryInfo.getAwards().size() == 0) {
				return MmochatUtil.msgbox(req.getHallState(), "奖品已经发完，无法抽奖!");
			}
			MmochatFastLotteryAward myAward = null;
			synchronized (fastPayLotteryInfo) {
				if (fastPayLotteryInfo.getAwards().size() == 0) {
					return MmochatUtil.msgbox(req.getHallState(),
							"奖品已经发完，无法抽奖!");
				}
				try {
					myAward = fastPayLotteryInfo.getAwards().remove(0);
				} catch (Exception e) {
					return MmochatUtil.msgbox(req.getHallState(),
							"奖品已经发完，无法抽奖!");
				}
			}
			if (myAward != null) {
				for (MmochatFastLotteryAwardTitle title : fastPayLotteryInfo
						.getAwardTitle()) {
					if (myAward.getMoneyType() == title.getMoneyType()
							&& myAward.getMoneyAward() == title.getMoneyAward()) {
						title.addCostNum(1);
						break;
					}
				}
				myInfo.addAwardTimes(-1);

				if (myAward.getMoneyAward() >= fastPayLotteryInfo.getBigValue()) {
					String msg = MmochatUtil.wrapColor(me.getName(),
							Color.green)
							+ "抽中了"
							+ myAward.getMoneyAward()
							+ myAward.getMoneyType().toString();
					fastPayLotteryInfo.addNewAwardInfo(msg);
				}

				// 发放奖励
				// 发送客服消息
				userInfo = "恭喜您抽中了"
						+ MmochatUtil.wrapColor(myAward.getMoneyAward()
								+ myAward.getMoneyType().toString(), Color.red);
				if (myAward.getMoneyType() == MmochatMoneyType.K币) {
					userInfo += "(K币奖励将在7个工作日内统一发放)!";
				} else if (myAward.getMoneyType() == MmochatMoneyType.人民币) {
					userInfo += "(现金奖励由客服发放，请注意客服消息通知)!";
				} else {
					userInfo += "(奖励已发放给您，请查收)!";
				}
				userInfo = MmochatUtil.wrapColor(userInfo, Color.yellow);
				MmochatGmService.sendKufuPrivateMsg(me.getRoleId(), userInfo,
						false);

				// 如果是金钱或元宝，则马上下发奖励(不能大于10000000，防止数据异常)
				int moneyCount = myAward.getMoneyAward();
				if (moneyCount > 0 && moneyCount < 10000000) {
					switch (myAward.getMoneyType()) {
					case 元宝: {
						me.addBig_money(moneyCount);
						try {
							MmochatDao.addRoleBigMoney(me.getRoleId(),
									moneyCount);
						} catch (Exception e) {
							e.printStackTrace();
						}
						break;
					}
					case 金钱: {
						try {
							me.addAndUpdateSmall_money(moneyCount);
						} catch (Exception e1) {
							e1.printStackTrace();
						}
						try {
							MmochatDao.addRoleSmallMoney(me.getRoleId(),
									moneyCount);
						} catch (Exception e) {
							e.printStackTrace();
						}
						break;
					}
					case K币:
					case 人民币: {
						// 保存数据库
						try {
							MmochatDao.addNewActivityRecord2(me.getSkyId(), me
									.getRoleId(), myAward.getMoneyAward(),
									fastPayLotteryInfo.getId(), myAward
											.getMoneyType().toString()
											+ ":" + me.getName());
						} catch (Exception e) {
							e.printStackTrace();
						}
						break;
					}
					default:
						break;
					}
				}
			}
		}

		CreateTlvWin tlv = getFastLotteryTlv(me);
		if (tlv == null) {
			return MmochatUtil.msgbox(req.getHallState(), "此活动尚未开始或已结束");
		}
		CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
		msgbox.setContent(new Text(userInfo));
		msgbox.setLeftName("确定");
		return MmochatUtil.tlvResponse(req.getHallState(), new CloseWinTLV(
				MmochatConstant.TLV_WIN_FASTLOTTERY), tlv, msgbox);
	}

	// 玩家系统
	@SuppressWarnings("deprecation")
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_28(SkymobiHandler handler,
			Mmochat_13_28C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		switch (req.getIndex()) {
		case 1: {
			// 玩家商会
			if (!MmochatConstant.isPlayerShopOpen) {
				return MmochatUtil.msgbox(req.getHallState(), "玩家商会临时维护中!");
			}

			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("确定");
			tlv.setRightName("返回");
			tlv.setTitle("玩家商会");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());

			CreateEditBoxTLV edit = new CreateEditBoxTLV();
			edit.setTitle("请输入商店ID");
			edit.setLeftName("查找");
			edit.setRightName("取消");
			edit.setContentLenMax(9);
			edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
			edit.setInputType(CreateEditBoxTLV.INPUT_ANY << 4);
			edit.addLeftTLV(new ClearDataTLV());
			edit.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
			edit.addLeftTLV(new AddEditBoxTLV());
			edit.addLeftTLV(new SendDataTLV(
					MmochatConstant.getClientModuleId(), MmochatMain
							.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_19_25, null));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(false);
			edit.addLeftTLV(wait);

			tlv.addItemEvent("查看所有商店", new ClearDataTLV(), new AddDataTLV(
					(int) 1), new SendDataTLV(MmochatConstant
					.getClientModuleId(), MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_19_9, (int) me
							.getRoleId()), new ShowWaitingMsgBoxTLV());

			tlv.addItemEvent("搜索指定商品", new ClearDataTLV(), new AddDataTLV(
					(int) 6), new SendDataTLV(MmochatConstant
					.getClientModuleId(), MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_19_9, (int) me
							.getRoleId()), new ShowWaitingMsgBoxTLV());

			tlv.addItemEvent("根据ID查找商店", edit);

			tlv.addItemEvent("进入我的商店", new ClearDataTLV(), new AddDataTLV(
					(int) 2), new SendDataTLV(MmochatConstant
					.getClientModuleId(), MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_19_9, (int) me
							.getRoleId()), new ShowWaitingMsgBoxTLV());

			tlv.addItemEvent("创建商店", new ClearDataTLV(),
					new AddDataTLV((int) 3), new SendDataTLV(MmochatConstant
							.getClientModuleId(),
							MmochatMain.getModuleInstID(),
							MmochatConstant.MSGCODE_MMOCHAT_C_19_9, (int) me
									.getRoleId()), new ShowWaitingMsgBoxTLV());

			tlv.addItemEvent("购买二手商店", new ClearDataTLV(), new AddDataTLV(
					(int) 4), new SendDataTLV(MmochatConstant
					.getClientModuleId(), MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_19_9, (int) me
							.getRoleId()), new ShowWaitingMsgBoxTLV());

			tlv.addItemEvent("掌柜手册", new ClearDataTLV(),
					new AddDataTLV((int) 5), new SendDataTLV(MmochatConstant
							.getClientModuleId(),
							MmochatMain.getModuleInstID(),
							MmochatConstant.MSGCODE_MMOCHAT_C_19_9, (int) me
									.getRoleId()), new ShowWaitingMsgBoxTLV());

			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 2: {
			// 元宝交易
			if (!MmochatConstant.isYBDealOpen) {
				return MmochatUtil.msgbox(req.getHallState(), "元宝交易临时维护中!");
			}
			if (MmochatNpcService.checkStorePwd(me)) {
				return null;
			}
			MmochatBigMoneyDealService.sendBigMoneyDealWnd2Person(me, req
					.getHallState(), 0, 0);
			return null;
		}
		case 3: {
			// 在线奖励
			if (!MmochatConstant.IsOnlineAwardOpen()) {
				return MmochatUtil.msgbox(req.getHallState(), "在线奖励活动已结束或未开始!");
			}
			if (me.getLevel() < 35) {
				return MmochatUtil.msgbox(req.getHallState(),
						"在线奖励只有36级(以上)才能领取噢，快点升级吧!");
			}
			CreateTlvWin tlv = getOnlineAwardTlv(me);
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 4: {
			// 出借找回
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("进入");
			tlv.setRightName("返回");
			tlv.setTitle("出借找回");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());

			tlv.addItemEvent("输入借方ID找回", new ClearDataTLV(), new AddDataTLV(
					(int) 1));
			tlv.addItemEvent("最近出借记录", new ClearDataTLV(), new AddDataTLV(
					(int) 2));

			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_13_33, (int) me
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 5: {
			// 官方线下交易
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("进入");
			tlv.setRightName("返回");
			tlv.setTitle("官方线下交易");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());

			tlv.addItemEvent("我要出售角色", new ClearDataTLV(), new AddDataTLV(
					(int) 2));
			tlv.addItemEvent("我要转号", new ClearDataTLV(),
					new AddDataTLV((int) 5));
			tlv.addItemEvent("我的角色订单", new ClearDataTLV(), new AddDataTLV(
					(int) 3));
			tlv.addItemEvent("我要出售财物", new ClearDataTLV(), new AddDataTLV(
					(int) 4));

			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_13_24, (int) me
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 6: {
			// 新闻角
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("查看");
			tlv.setRightName("返回");
			tlv.setTitle("新闻角");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());

			for (MmochatQQNewsType type : MmochatQQNewsType.values()) {
				String item = type.toString();
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) type.getKey()));
			}
			tlv.addItemEvent("新闻角说明", new ClearDataTLV(), new AddDataTLV(
					(int) -1));

			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_13_30, (int) me
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 7: {
			// 战斗录像
			if (!MmochatConstant.isBattleRecordOpen) {
				return MmochatUtil.msgbox(req.getHallState(), "此功能暂未开放!");
			}
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("查看");
			tlv.setRightName("返回");
			tlv.setTitle("战斗录像");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());

			tlv
					.addItemEvent("武道会", new ClearDataTLV(), new AddDataTLV(
							(int) 1));
			tlv.addItemEvent("个人争霸赛", new ClearDataTLV(), new AddDataTLV(
					(int) 2));
			tlv.addItemEvent("天下第一争霸赛", new ClearDataTLV(), new AddDataTLV(
					(int) 3));
			tlv.addItemEvent("玩家录像", new ClearDataTLV(),
					new AddDataTLV((int) 4));

			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_13_31, (int) me
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 8: {
			return MmochatNpcService.getNpcTlv(me, 72);
		}
		case 9: {
			// 石头剪刀布
			if (!MmochatConstant.isStoneBetOpen) {
				return MmochatUtil.msgbox(req.getHallState(), "此功能暂未开放!");
			}
			if (MmochatNpcService.checkStorePwd(me)) {
				return null;
			}
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("进入");
			tlv.setRightName("返回");
			tlv.setTitle("石头剪刀布比赛");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());

			tlv.addItemEvent("查看所有比赛", new ClearDataTLV(), new AddDataTLV(
					(int) 1));
			tlv.addItemEvent("发布我的比赛", new ClearDataTLV(), new AddDataTLV(
					(int) 2));
			tlv.addItemEvent("查看我的比赛", new ClearDataTLV(), new AddDataTLV(
					(int) 3));

			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_21_1, (int) me
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		default:
			return MmochatUtil.msgbox(req.getHallState(), "此功能暂未开放!");
		}
	}

	// 新闻分类
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_30(SkymobiHandler handler,
			Mmochat_13_30C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		if (req.getNewsTypeId() == -1) {
			// 说明
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle("新闻角说明");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());
			String content = "";
			content += MmochatUtil.wrapColor("[免责声明]\n", Color.yellow);
			content += "新闻角所有新闻内容来源为网上免费公开发布的内容，版权归新闻发布者所有，"
					+ "不代表仙剑问情官方赞成此新闻的内容或立场!\n\n";
			content += MmochatUtil.wrapColor("[更新说明]\n", Color.yellow);
			content += "正常情况下，新闻内容每天更新，让您看到的都是当天最新的新闻，更新频率为10分钟一次，"
					+ "每次可能会更新1~2条新闻内容。\n\n";
			content += MmochatUtil.wrapColor("[其它说明]\n", Color.yellow);
			content += "新闻角最终解释权归仙剑问情官方所有，官方可以在不通知用户的情况下，" + "根据情况需要随机关停此服务。";
			tlv.setContent(new Text(content));
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		} else {
			MmochatQQNewsType newsType = MmochatQQNewsType.get(req
					.getNewsTypeId());
			if (newsType == null) {
				return MmochatUtil.msgbox(req.getHallState(), "暂无此类新闻!");
			}
			List<MmochatNews> newsList = MmochatNewsService
					.getLatestNews(newsType);
			if (newsList.size() == 0) {
				return MmochatUtil.msgbox(req.getHallState(),
						"暂时没有新闻数据，请过几分钟再试!");
			}
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("详情");
			tlv.setRightName("返回");
			tlv.setTitle("隔10分钟更新");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());

			int index = 1;
			for (MmochatNews news : newsList) {
				String item = MmochatUtil.wrapColor(index + "、", Color.yellow);
				item += news.getTitle();
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) news.getId()));
				index++;
			}
			tlv.addLeftTLV(new AddDataTLV((int) 0));
			tlv.addLeftTLV(new AddDataTLV((int) newsType.getKey()));
			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_13_29, (int) me
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
	}

	// 新闻内容
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_29(SkymobiHandler handler,
			Mmochat_13_29C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatQQNewsType newsType = MmochatQQNewsType.get(req.getNewsType());
		if (newsType == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无此类新闻!");
		}
		Map<Integer, MmochatNews> subNews = MmochatNewsService.newsMap
				.get(newsType);
		if (subNews == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无此类新闻!");
		}
		MmochatNews news = subNews.get(req.getNewsId());
		if (news == null) {
			return MmochatUtil.msgbox(req.getHallState(), "该条新闻已过期，请刷新列表后查看!");
		}
		int page = req.getPage();
		if (page == 0) {
			news.addHit();
			MmochatNewsService.totalNewsHit++;
		}
		if (page < 0) {
			page = 0;
		}
		int totalPage = news.getPageNum();
		if (page >= totalPage) {
			page = totalPage - 1;
		}
		String curPageInfo = "";
		if (page < news.getContent().size()) {
			curPageInfo = news.getContent().get(page);
		}

		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinId(MmochatConstant.TLV_WIN_NEWS);
		tlv.setWinType(WinType.Text);
		if (totalPage > 1 && page < totalPage - 1) {
			tlv.setLeftName("下页");

			tlv.addLeftTLV(new AddDataTLV((int) news.getId()));
			tlv.addLeftTLV(new AddDataTLV((int) (page + 1)));
			tlv.addLeftTLV(new AddDataTLV((int) newsType.getKey()));
			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_13_29, (int) me
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());
		}
		tlv.setRightName("返回");
		tlv.setTitle("新闻详情");
		tlv.setWinHeight(208);
		tlv.addRightTLV(new CloseWinTLV(MmochatConstant.TLV_WIN_NEWS));
		String content = "";
		content += MmochatUtil.wrapColor(news.getTitle() + "\n", Color.yellow);
		content += MmochatUtil.wrapColor("点击:" + news.getHit() + " 页码:"
				+ (page + 1) + "\n", Color.green);
		content += curPageInfo;
		tlv.setContent(new Text(content));
		return MmochatUtil.tlvResponse(req.getHallState(), new CloseWinTLV(
				MmochatConstant.TLV_WIN_NEWS), tlv);
	}

	// 查看录像
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_31(SkymobiHandler handler,
			Mmochat_13_31C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		String title = "";
		MmochatBattleType battleType = null;
		switch (req.getIndex()) {
		case 1:
			battleType = MmochatBattleType.武道会比赛;
			break;
		case 2:
			battleType = MmochatBattleType.个人争霸赛;
			break;
		case 3:
			battleType = MmochatBattleType.天下第一争霸赛;
			break;
		default:
			break;
		}
		if (battleType != null) {
			title = battleType.toString();
		} else {
			title = "玩家录像";
		}

		List<MmochatBattleRecord> records = new ArrayList<MmochatBattleRecord>();
		for (MmochatBattleRecord r : MmochatBattleService.battleRecords
				.values()) {
			if (battleType == null) {
				// 玩家录像
				if (r.getType() != MmochatBattleType.武道会比赛
						&& r.getType() != MmochatBattleType.个人争霸赛
						&& r.getType() != MmochatBattleType.天下第一争霸赛
						&& r.getType() != MmochatBattleType.跨服武道会比赛) {
					records.add(r);
				}
			} else if (r.getType() == battleType) {
				records.add(r);
			}
		}
		if (records.size() == 0) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无此类录像!");
		}
		Collections.sort(records);

		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.List);
		tlv.setLeftName("观战");
		tlv.setRightName("返回");
		tlv.setTitle(title);
		tlv.setWinHeight(208);
		tlv.addRightTLV(new CloseWinTLV());

		int index = 1;
		SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
		for (MmochatBattleRecord r : records) {
			String item = index + "、"
					+ MmochatUtil.wrapColor(r.getName1(), Color.yellow)
					+ MmochatUtil.wrapIcon(MmochatConstant.BMP_EMOTION_32)
					+ MmochatUtil.wrapColor(r.getName2(), Color.yellow) + "\n";
			item += r.getType().toString() + "\n";
			String t = sdf.format(new Date(r.getStartTick()));
			item += t;
			tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV((int) r
					.getId()));
			if (index >= MmochatConstant.maxRecordNumShow) {
				break;
			}
			index++;
		}
		tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_13_32, (int) me.getRoleId()));
		tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

		return MmochatUtil.tlvResponse(req.getHallState(), tlv);
	}

	// 查看录像
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_32(SkymobiHandler handler,
			Mmochat_13_32C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatMap curMap = MmochatMapService.getMapByMapId(me.getMapId());
		if (!curMap.isCanWatchPk()) {
			return MmochatUtil.msgbox(req.getHallState(), "本地图内不允许观看录像!");
		}
		if (MmochatTeamService.getTeamState(me) == MmochatTeamStateType.队员) {
			return MmochatUtil.msgbox(req.getHallState(), "在队伍中不允许观看录像!");
		}
		if (me.isInBattle() || me.isInWatchingBattle()) {
			return null;
		}
		MmochatBattleService.watchBattleRecord(me.getRoleId(), req
				.getBattleId());
		return null;
	}

	// 出借找回
	@SuppressWarnings("deprecation")
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_33(SkymobiHandler handler,
			Mmochat_13_33C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		switch (req.getIndex()) {
		case 1: {
			// 根据ID找回
			// 判断是否为跨服武道时间
			Date now = new Date();
			if ((now.getDay() == 4)
					&& ((now.getHours() == 19) || (now.getHours() == 20))) {
				return MmochatUtil.msgbox(req.getHallState(),
						"每周四19:00-21:00期间，不允许物品出借找回!请下个时段进行找回。");
			}
			// 借出找回
			CreateEditBoxTLV edit = new CreateEditBoxTLV();
			edit
					.setTitle(MmochatUtil.wrapColor("请输入借方的角色ID!\n",
							Color.yellow)
							+ "自助找回需要消耗"
							+ MmochatUtil
									.getColorMoney(MmochatConstant.moneyNeedForGetBackBorrowed)
							+ "文钱(找回物品请先清理出相应数量的包裹空位。"
							+ "对方若没有您出借的物品，本次操作仍会扣除金钱)");
			edit.setLeftName("找回");
			edit.setRightName("取消");
			edit.setContentLenMax(9);
			edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
			edit.setInputType(CreateEditBoxTLV.INPUT_ANY << 4);
			edit.addLeftTLV(new ClearDataTLV());
			edit.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
			edit.addLeftTLV(new AddEditBoxTLV());
			edit.addLeftTLV(new SendDataTLV(
					MmochatConstant.getClientModuleId(), MmochatMain
							.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_13_25, null));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(false);
			edit.addLeftTLV(wait);
			return MmochatUtil.tlvResponse(req.getHallState(), edit);
		}
		case 2: {
			// 出借记录
			List<MmochatBorrowRecord> myList = MmochatDealService.borrowLog
					.get(me.getRoleId());
			if (myList == null || myList.size() == 0) {
				return MmochatUtil.msgbox(req.getHallState(),
						"自上次服务器维护之后，您没有借出过财物。\n如果在这之前您借出了物品而忘记对方ID，"
								+ "请联系客服帮忙查询，客服电话:0571-85222407");
			}

			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("找回");
			tlv.setRightName("返回");
			tlv.setTitle("最近出借记录");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());

			Collections.sort(myList);
			SimpleDateFormat secFormat = new SimpleDateFormat("MM月dd号");
			for (MmochatBorrowRecord r : myList) {
				String time = secFormat.format(new Date(r.getTime()));
				String item = MmochatUtil.wrapColor("借方:" + r.getName() + "\n",
						Color.yellow);
				item += "ID:" + Integer.toHexString(r.getBorrowId() * 3) + "\n";
				item += "时间:" + time;
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) r.getBorrowId()));
			}
			tlv
					.addItemEvent(
							MmochatUtil
									.wrapColor(
											"提示:只记录上次维护后的记录，更多记录请联系客服。找回需消耗"
													+ MmochatUtil
															.getColorMoney(MmochatConstant.moneyNeedForGetBackBorrowed)
													+ "文钱!", Color.red),
							new ClearDataTLV(), new AddDataTLV((int) -1));
			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_13_34, (int) me
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		default:
			break;
		}
		return null;
	}

	// 出借找回
	@SkymobiService
	public SkymobiProtocolMessage handleC_13_34(SkymobiHandler handler,
			Mmochat_13_34C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		int borrowerId = req.getBorrowId();
		if (me.getRoleId() == borrowerId) {
			return MmochatUtil.msgbox(req.getHallState(), "不能向您自己找回物品!");
		}
		if (me.getSmall_money() < MmochatConstant.moneyNeedForGetBackBorrowed) {
			return MmochatUtil.msgbox(req.getHallState(), "自助找回需要"
					+ MmochatConstant.moneyNeedForGetBackBorrowed
					+ "文钱，您包裹里的金钱不足!");
		}

		int packNum = me.getPackageSpaceNum();

		MmochatPlayer he = MmochatGmService.getRoleInfoById(borrowerId);
		if (he == null) {
			return MmochatUtil.msgbox(req.getHallState(), "您查找的角色不存在!");
		}

		if (he.isInBattle()) {
			return MmochatUtil.msgbox(req.getHallState(), "对方当前正在战斗中，请稍候再试!");
		}

		String msg;
		String hisMsg;
		synchronized (me) {
			// 扣钱
			me.addAndUpdateSmall_money(-1
					* MmochatConstant.moneyNeedForGetBackBorrowed);
			try {
				MmochatDao.updateRoleSmallMoney(me);
			} catch (Exception e) {
				e.printStackTrace();
				me
						.addAndUpdateSmall_money(MmochatConstant.moneyNeedForGetBackBorrowed);
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
			}
			msg = "";
			hisMsg = "";
			// 找回宠物
			boolean hasPet = false;
			List<MmochatPet> petList = new ArrayList<MmochatPet>();
			List<MmochatPet> storePetList = new ArrayList<MmochatPet>();
			for (MmochatPet pet : he.getPets().values()) {
				if (pet != null && pet.getBorrowFromRoleId() != null
						&& pet.getBorrowFromRoleId() == me.getRoleId()) {
					petList.add(pet);
					he.getPets().remove(pet.getId());
					pet.setBorrowFromRoleId(null);
					pet.setState(MmochatPetStateType.休息);
					me.getStoredPets().put(pet.getId(), pet);
					hasPet = true;
				}
			}
			for (MmochatPet pet : he.getStoredPets().values()) {
				if (pet != null && pet.getBorrowFromRoleId() != null
						&& pet.getBorrowFromRoleId() == me.getRoleId()) {
					storePetList.add(pet);
					he.getStoredPets().remove(pet.getId());
					pet.setBorrowFromRoleId(null);
					pet.setState(MmochatPetStateType.休息);
					me.getStoredPets().put(pet.getId(), pet);
					hasPet = true;
				}
			}
			if (hasPet) {
				try {
					MmochatDao.getBorrowedPetBack(me, he);
				} catch (Exception e) {
					e.printStackTrace();
					for (MmochatPet pet : petList) {
						pet.setBorrowFromRoleId(me.getRoleId());
						he.addPet(pet);
						me.getStoredPets().remove(pet.getId());
					}
					for (MmochatPet pet : storePetList) {
						pet.setBorrowFromRoleId(me.getRoleId());
						he.getStoredPets().put(pet.getId(), pet);
						me.getStoredPets().remove(pet.getId());
					}
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}
				msg += "您借出的宠物已经找回，请到" + MmochatUtil.wrapColor("钱庄", Color.red)
						+ "领取!\n";
				hisMsg += "您向"
						+ MmochatUtil.wrapColor(me.getName(), Color.green)
						+ "借的宠物已经被对方找回!\n";
			}
			// 包裹找回物品
			boolean updatePackage = false;
			String tail = "";
			List<MmochatCommonObject> objList = new ArrayList<MmochatCommonObject>();
			List<MmochatCommonObject> storeObjList = new ArrayList<MmochatCommonObject>();
			if (packNum > 0) {
				for (MmochatPackageGrid grid : he.getMyPackage().values()) {
					if (grid != null) {
						MmochatCommonObject obj = grid.getObject();
						if (obj != null && obj.getBorrowFromRoleId() != null
								&& obj.getBorrowFromRoleId() == me.getRoleId()) {
							updatePackage = true;
							objList.add(obj);
							if (grid.getGridType() == MmochatPackageGridType.身上装备格子) {
								// 先卸下
								// 判断卸下之前是否是一身套装
								boolean isSet = he
										.isAllWeaponedEquipTheSameSet();
								// 更新装备使用者
								grid.getObject().setEquipUserRoleId(null);
								grid.setObject(null);
								// 下发更新包裹数据
								Mmochat_5_1S pack = new Mmochat_5_1S();
								if (isSet) {
									// 如果是套装，需要更新4件套装备和套装效果
									MmochatPackageGrid grid1 = he
											.getMyPackage().get(
													MmochatEquipPlaceType.头部
															.getValue());
									if (grid1 != null) {
										pack.addGrid(grid1);
									}
									grid1 = he.getMyPackage()
											.get(
													MmochatEquipPlaceType.手上
															.getValue());
									if (grid1 != null) {
										pack.addGrid(grid1);
									}
									grid1 = he.getMyPackage()
											.get(
													MmochatEquipPlaceType.身体
															.getValue());
									if (grid1 != null) {
										pack.addGrid(grid1);
									}
									grid1 = he.getMyPackage().get(
											MmochatEquipPlaceType.脚.getValue());
									if (grid1 != null) {
										pack.addGrid(grid1);
									}

									// 更新套装效果
									Mmochat_1_16S effect = new Mmochat_1_16S();
									effect.setMe(he);
									MmochatUtil.sendCommonPack(he, effect);
								}
								pack.addGrid(grid);
								MmochatUtil.sendCommonPack(he, pack);
							} else {
								grid.setObject(null);
								// 下发更新包裹数据
								Mmochat_5_1S pack = new Mmochat_5_1S();
								pack.addGrid(grid);
								MmochatUtil.sendCommonPack(he, pack);
							}
							obj.setBorrowFromRoleId(null);
							me.addObjectToPackage(obj);
							packNum = me.getPackageSpaceNum();
							if (packNum <= 0) {
								tail = "您的包裹已满，如果还有未找回物品，请清理出空位后继续找回。";
								break;
							}
						}
					}
				}
			}
			// 钱庄找回
			if (packNum > 0) {
				for (MmochatPackageGrid grid : he.getMyStorage().values()) {
					if (grid != null) {
						MmochatCommonObject obj = grid.getObject();
						if (obj != null && obj.getBorrowFromRoleId() != null
								&& obj.getBorrowFromRoleId() == me.getRoleId()) {
							updatePackage = true;
							storeObjList.add(obj);

							grid.setObject(null);
							obj.setBorrowFromRoleId(null);
							me.addObjectToPackage(obj);
							packNum = me.getPackageSpaceNum();
							if (packNum <= 0) {
								tail = "您的包裹已满，如果还有未找回物品，请清理出空位后继续找回。";
								break;
							}
						}
					}
				}
			}
			if (updatePackage) {
				try {
					MmochatDao.getBorrowedObjBack(me, he);
				} catch (Exception e) {
					e.printStackTrace();
					for (MmochatCommonObject obj : objList) {
						obj.setBorrowFromRoleId(me.getRoleId());
						boolean ret = he.addObjectToPackage(obj);
						if (!ret) {
							he.addObjectToStorage(obj);
						}
						me.delPackageObjById(obj.getId());
					}
					for (MmochatCommonObject obj : storeObjList) {
						obj.setBorrowFromRoleId(me.getRoleId());
						he.addObjectToStorage(obj);
						me.delPackageObjById(obj.getId());
					}
					return MmochatUtil.msgbox(req.getHallState(), msg
							+ "\n服务器忙,请稍候再试!");
				}
				// 更新人物状态
				Mmochat_1_16S pack = new Mmochat_1_16S();
				pack.setMe(he);
				MmochatUtil.sendCommonPack(he, pack);

				msg += "您借出的物品已经找回到您的" + MmochatUtil.wrapColor("包裹", Color.red)
						+ "!" + tail;
				hisMsg += "您向"
						+ MmochatUtil.wrapColor(me.getName(), Color.green)
						+ "借的物品已经被对方找回!\n";
			}
			if (!updatePackage && !hasPet) {
				if (packNum == 0) {
					return MmochatUtil.msgbox(req.getHallState(),
							"您的包裹已满，请先清理出一定的空位!");
				}
				return MmochatUtil.msgbox(req.getHallState(),
						"对方身上没有从您这借的财物，可能是您已经找回，或未借给对方过!本次找回消耗"
								+ MmochatConstant.moneyNeedForGetBackBorrowed
								+ "文钱!");
			}
		}
		MmochatGmService.sendKufuPrivateMsg(he.getRoleId(), hisMsg, false);
		MmochatGmService.sendKufuPrivateMsg(me.getRoleId(), msg, false);
		MmochatChatService.sendSystemMsgToPerson(me, msg);
		return MmochatUtil.msgbox(req.getHallState(), msg);
	}
}
